values_unittest.nc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // This is a "No Compile Test" suite.
  5. // http://dev.chromium.org/developers/testing/no-compile-tests
  6. #include "base/values.h"
  7. #include <stdint.h>
  8. namespace base {
  9. void G(ValueView v) {}
  10. #if defined(NCTEST_VALUE_CTOR_PTR_DOES_NOT_CONVERT_TO_BOOL) // [r"fatal error: call to deleted constructor"]
  11. void F() {
  12. int* ptr = nullptr;
  13. Value v(ptr);
  14. }
  15. #elif defined(NCTEST_DICT_SET_PTR_DOES_NOT_CONVERT_TO_BOOL) // [r"fatal error: call to deleted member function"]
  16. void F() {
  17. int* ptr = nullptr;
  18. Value::Dict dict;
  19. dict.Set("moo", ptr);
  20. }
  21. #elif defined(NCTEST_DICT_SETBYDOTTEDPATH_PTR_DOES_NOT_CONVERT_TO_BOOL) // [r"fatal error: call to deleted member function"]
  22. void F() {
  23. int* ptr = nullptr;
  24. Value::Dict dict;
  25. dict.SetByDottedPath("moo.moo", ptr);
  26. }
  27. #elif defined(NCTEST_LIST_APPEND_PTR_DOES_NOT_CONVERT_TO_BOOL) // [r"fatal error: call to deleted member function"]
  28. void F() {
  29. int* ptr = nullptr;
  30. Value::List list;
  31. list.Append(ptr);
  32. }
  33. #elif defined(NCTEST_VALUE_CTOR_INT64_T) // [r"fatal error: ambiguous conversion for functional-style cast from 'int64_t' \(aka '.+?'\) to 'Value'"]
  34. Value F(int64_t value) {
  35. return Value(value);
  36. }
  37. #elif defined(NCTEST_SET_INT64_T) // [r"fatal error: call to member function 'Set' is ambiguous"]
  38. Value::Dict F(int64_t value) {
  39. Value::Dict dict;
  40. dict.Set("あいうえお", value);
  41. return dict;
  42. }
  43. #elif defined(NCTEST_SETBYDOTTEDPATH_INT64_T) // [r"fatal error: call to member function 'SetByDottedPath' is ambiguous"]
  44. Value::Dict F(int64_t value) {
  45. Value::Dict dict;
  46. dict.SetByDottedPath("あいうえお", value);
  47. return dict;
  48. }
  49. #elif defined(NCTEST_LIST_APPEND_INT64_T) // [r"fatal error: call to member function 'Append' is ambiguous"]
  50. Value::List F(int64_t value) {
  51. Value::List list;
  52. list.Append(value);
  53. return list;
  54. }
  55. #elif defined(NCTEST_VALUEVIEW_FROM_CONST_NON_CHAR_POINTER) // [r"fatal error: conversion function from 'const int \*' to 'ValueView' invokes a deleted function"]
  56. void F() {
  57. const int* ptr = nullptr;
  58. ValueView v = ptr;
  59. G(v);
  60. }
  61. #elif defined(NCTEST_VALUEVIEW_FROM_NON_CHAR_POINTER) // [r"fatal error: conversion function from 'int \*' to 'ValueView' invokes a deleted function"]
  62. void F() {
  63. int* ptr = nullptr;
  64. ValueView v = ptr;
  65. G(v);
  66. }
  67. #elif defined(NCTEST_VALUEVIEW_FROM_STRING_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"]
  68. void F() {
  69. ValueView v = std::string();
  70. G(v);
  71. }
  72. #elif defined(NCTEST_VALUEVIEW_FROM_BLOB_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"]
  73. void F() {
  74. ValueView v = Value::BlobStorage();
  75. G(v);
  76. }
  77. #elif defined(NCTEST_VALUEVIEW_FROM_DICT_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"]
  78. void F() {
  79. ValueView v = Value::Dict();
  80. G(v);
  81. }
  82. #elif defined(NCTEST_VALUEVIEW_FROM_LIST_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"]
  83. void F() {
  84. ValueView v = Value::List();
  85. G(v);
  86. }
  87. #elif defined(NCTEST_VALUEVIEW_FROM_VALUE_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"]
  88. void F() {
  89. ValueView v = Value();
  90. G(v);
  91. }
  92. #endif
  93. } // namespace base