| 1 | // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributorscxx . . $ `<file>/src/kj/parse/char-test.c++`/ |
| 2 | // Licensed under the MIT License: |
| 3 | // |
| 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | // of this software and associated documentation files (the "Software"), to deal |
| 6 | // in the Software without restriction, including without limitation the rights |
| 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 | // copies of the Software, and to permit persons to whom the Software is |
| 9 | // furnished to do so, subject to the following conditions: |
| 10 | // |
| 11 | // The above copyright notice and this permission notice shall be included in |
| 12 | // all copies or substantial portions of the Software. |
| 13 | // |
| 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 20 | // THE SOFTWARE. |
| 21 | |
| 22 | #include "char.h"cxx . . $ `<file>/src/kj/parse/char.h`/ |
| 23 | #include "../string.h"cxx . . $ `<file>/src/kj/string.h`/ |
| 24 | #include <kj/compat/gtest.h>cxx . . $ `<file>/src/kj/compat/gtest.h`/ |
| 25 | |
| 26 | namespace kjcxx . . $ kj/ { |
| 27 | namespace parsecxx . . $ kj/parse/ { |
| 28 | namespacecxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/ { |
| 29 | |
| 30 | typedef IteratorInputcxx . . $ kj/parse/IteratorInput#<char, const char*> Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input#; |
| 31 | typedef Spancxx . . $ kj/parse/Span#<const char*> TestLocationcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/TestLocation#; |
| 32 | |
| 33 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, ExactChar) { |
| 34 | constexpr auto parser = exactCharcxx . . $ kj/parse/exactChar(4aa50fc59ab31e8f).<'a'>(); |
| 35 | |
| 36 | { |
| 37 | StringPtrcxx . . $ kj/StringPtr# text = "a"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 38 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 39 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(parser(input) != nullptr); |
| 40 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 41 | } |
| 42 | |
| 43 | { |
| 44 | StringPtrcxx . . $ kj/StringPtr# text = "b"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 45 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 46 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(parser(input) == nullptr); |
| 47 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, ExactString) { |
| 52 | constexpr auto parser = exactStringcxx . . $ kj/parse/exactString(cbfcc618623ba004).("foo"); |
| 53 | |
| 54 | { |
| 55 | StringPtrcxx . . $ kj/StringPtr# text = "foobar"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 56 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 57 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(parser(input) != nullptr); |
| 58 | ASSERT_FALSEcxx . . $ `src/kj/compat/gtest.h:66:9`!(input.atEnd()); |
| 59 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!('b', input.current()); |
| 60 | } |
| 61 | |
| 62 | { |
| 63 | StringPtrcxx . . $ kj/StringPtr# text = "bar"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 64 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 65 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(parser(input) == nullptr); |
| 66 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 67 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!('b', input.current()); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, CharRange) { |
| 72 | constexpr auto parser = charRangecxx . . $ kj/parse/charRange(bb8bf3b4e8097fd).('a', 'z'); |
| 73 | |
| 74 | { |
| 75 | StringPtrcxx . . $ kj/StringPtr# text = "a"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 76 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 77 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 78 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 79 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!('a', *value); |
| 80 | } else { |
| 81 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected parse result, got null."; |
| 82 | } |
| 83 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 84 | } |
| 85 | |
| 86 | { |
| 87 | StringPtrcxx . . $ kj/StringPtr# text = "n"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 88 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 89 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 90 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 91 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!('n', *value); |
| 92 | } else { |
| 93 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected parse result, got null."; |
| 94 | } |
| 95 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 96 | } |
| 97 | |
| 98 | { |
| 99 | StringPtrcxx . . $ kj/StringPtr# text = "z"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 100 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 101 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 102 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 103 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!('z', *value); |
| 104 | } else { |
| 105 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected parse result, got null."; |
| 106 | } |
| 107 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 108 | } |
| 109 | |
| 110 | { |
| 111 | StringPtrcxx . . $ kj/StringPtr# text = "`"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 112 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 113 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 114 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(result == nullptr); |
| 115 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 116 | } |
| 117 | |
| 118 | { |
| 119 | StringPtrcxx . . $ kj/StringPtr# text = "{"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 120 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 121 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 122 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(result == nullptr); |
| 123 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 124 | } |
| 125 | |
| 126 | { |
| 127 | StringPtrcxx . . $ kj/StringPtr# text = "A"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 128 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 129 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 130 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(result == nullptr); |
| 131 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, AnyOfChars) { |
| 136 | constexpr auto parser = anyOfCharscxx . . $ kj/parse/anyOfChars(31895926eb89ed72).("axn2B"); |
| 137 | |
| 138 | { |
| 139 | StringPtrcxx . . $ kj/StringPtr# text = "a"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 140 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 141 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 142 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 143 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!('a', *value); |
| 144 | } else { |
| 145 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected parse result, got null."; |
| 146 | } |
| 147 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 148 | } |
| 149 | |
| 150 | { |
| 151 | StringPtrcxx . . $ kj/StringPtr# text = "n"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 152 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 153 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 154 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 155 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!('n', *value); |
| 156 | } else { |
| 157 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected parse result, got null."; |
| 158 | } |
| 159 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 160 | } |
| 161 | |
| 162 | { |
| 163 | StringPtrcxx . . $ kj/StringPtr# text = "B"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 164 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 165 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 166 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 167 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!('B', *value); |
| 168 | } else { |
| 169 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected parse result, got null."; |
| 170 | } |
| 171 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 172 | } |
| 173 | |
| 174 | { |
| 175 | StringPtrcxx . . $ kj/StringPtr# text = "b"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 176 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 177 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 178 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(result == nullptr); |
| 179 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 180 | } |
| 181 | |
| 182 | { |
| 183 | StringPtrcxx . . $ kj/StringPtr# text = "j"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 184 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 185 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 186 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(result == nullptr); |
| 187 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 188 | } |
| 189 | |
| 190 | { |
| 191 | StringPtrcxx . . $ kj/StringPtr# text = "A"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 192 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 193 | Maybecxx . . $ kj/Maybe#<char> result = parser(cxx . . $ kj/parse/CharGroup_#`operator()`(2cf810e65be387d5).input); |
| 194 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(result == nullptr); |
| 195 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, CharGroupCombo) { |
| 200 | constexpr auto parser = |
| 201 | manycxx . . $ kj/parse/many(96f53bdb84fc3450).(charRangecxx . . $ kj/parse/charRange(bb8bf3b4e8097fd).('0', '9').orRangecxx . . $ kj/parse/CharGroup_#orRange(8b031fd02ba9a590).('a', 'z').orRangecxx . . $ kj/parse/CharGroup_#orRange(8b031fd02ba9a590).('A', 'Z').orAnycxx . . $ kj/parse/CharGroup_#orAny(f913b714ec911aa5).("-_")); |
| 202 | |
| 203 | { |
| 204 | StringPtrcxx . . $ kj/StringPtr# text = "foo1-bar2_baz3@qux"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 205 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 206 | Maybecxx . . $ kj/Maybe#<Arraycxx . . $ kj/Array#<char>> result = parser(cxx . . $ kj/parse/Many_#`operator()`(355132f7fc23ea62).input); |
| 207 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 208 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!("foo1-bar2_baz3", str(*value)); |
| 209 | } else { |
| 210 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected parse result, got null."; |
| 211 | } |
| 212 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, Identifier) { |
| 217 | constexpr auto parser = identifiercxx . . $ kj/parse/identifier.; |
| 218 | |
| 219 | { |
| 220 | StringPtrcxx . . $ kj/StringPtr# text = "helloWorld123 "cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 221 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 222 | Maybecxx . . $ kj/Maybe#<Stringcxx . . $ kj/String#> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 223 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 224 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!("helloWorld123", *value); |
| 225 | } else { |
| 226 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected string, got null."; |
| 227 | } |
| 228 | EXPECT_FALSEcxx . . $ `src/kj/compat/gtest.h:54:9`!(input.atEnd()); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, Integer) { |
| 233 | constexpr auto parser = integercxx . . $ kj/parse/integer.; |
| 234 | |
| 235 | { |
| 236 | StringPtrcxx . . $ kj/StringPtr# text = "12349"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 237 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 238 | Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> result = parser(cxx . . $ kj/parse/Sequence_#`operator()`(6e91475ba6a9a785).input); |
| 239 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 240 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!(12349u, *value); |
| 241 | } else { |
| 242 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected integer, got null."; |
| 243 | } |
| 244 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 245 | } |
| 246 | |
| 247 | { |
| 248 | StringPtrcxx . . $ kj/StringPtr# text = "0x1aF0"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 249 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 250 | Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> result = parser(cxx . . $ kj/parse/Sequence_#`operator()`(6e91475ba6a9a785).input); |
| 251 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 252 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!(0x1aF0u, *value); |
| 253 | } else { |
| 254 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected integer, got null."; |
| 255 | } |
| 256 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 257 | } |
| 258 | |
| 259 | { |
| 260 | StringPtrcxx . . $ kj/StringPtr# text = "064270"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 261 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 262 | Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> result = parser(cxx . . $ kj/parse/Sequence_#`operator()`(6e91475ba6a9a785).input); |
| 263 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 264 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!(064270u, *value); |
| 265 | } else { |
| 266 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected integer, got null."; |
| 267 | } |
| 268 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, Number) { |
| 273 | constexpr auto parser = numbercxx . . $ kj/parse/number.; |
| 274 | |
| 275 | { |
| 276 | StringPtrcxx . . $ kj/StringPtr# text = "12345"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 277 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 278 | Maybecxx . . $ kj/Maybe#<double> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 279 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 280 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!(12345, *value); |
| 281 | } else { |
| 282 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected number, got null."; |
| 283 | } |
| 284 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 285 | } |
| 286 | |
| 287 | { |
| 288 | StringPtrcxx . . $ kj/StringPtr# text = "123.25"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 289 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 290 | Maybecxx . . $ kj/Maybe#<double> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 291 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 292 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!(123.25, *value); |
| 293 | } else { |
| 294 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected number, got null."; |
| 295 | } |
| 296 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 297 | } |
| 298 | |
| 299 | { |
| 300 | StringPtrcxx . . $ kj/StringPtr# text = "123e10"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 301 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 302 | Maybecxx . . $ kj/Maybe#<double> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 303 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 304 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!(123e10, *value); |
| 305 | } else { |
| 306 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected number, got null."; |
| 307 | } |
| 308 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 309 | } |
| 310 | |
| 311 | { |
| 312 | StringPtrcxx . . $ kj/StringPtr# text = "123.25E+10"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 313 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 314 | Maybecxx . . $ kj/Maybe#<double> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 315 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 316 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!(123.25E+10, *value); |
| 317 | } else { |
| 318 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected number, got null."; |
| 319 | } |
| 320 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 321 | } |
| 322 | |
| 323 | { |
| 324 | StringPtrcxx . . $ kj/StringPtr# text = "25e-2"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 325 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 326 | Maybecxx . . $ kj/Maybe#<double> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 327 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 328 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!(25e-2, *value); |
| 329 | } else { |
| 330 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected number, got null."; |
| 331 | } |
| 332 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, DoubleQuotedString) { |
| 337 | constexpr auto parser = doubleQuotedStringcxx . . $ kj/parse/doubleQuotedString.; |
| 338 | |
| 339 | { |
| 340 | StringPtrcxx . . $ kj/StringPtr# text = "\"hello\""cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 341 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 342 | Maybecxx . . $ kj/Maybe#<Stringcxx . . $ kj/String#> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 343 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 344 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!("hello", *value); |
| 345 | } else { |
| 346 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected \"hello\", got null."; |
| 347 | } |
| 348 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 349 | } |
| 350 | |
| 351 | { |
| 352 | StringPtrcxx . . $ kj/StringPtr# text = "\"test\\a\\b\\f\\n\\r\\t\\v\\\'\\\"\\\?\\x01\\x20\\2\\34\\156\""cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 353 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 354 | Maybecxx . . $ kj/Maybe#<Stringcxx . . $ kj/String#> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 355 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 356 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!("test\a\b\f\n\r\t\v\'\"\?\x01\x20\2\34\156", *value); |
| 357 | } else { |
| 358 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected string, got null."; |
| 359 | } |
| 360 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 361 | } |
| 362 | |
| 363 | { |
| 364 | StringPtrcxx . . $ kj/StringPtr# text = "\"foo'bar\""cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 365 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 366 | Maybecxx . . $ kj/Maybe#<Stringcxx . . $ kj/String#> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 367 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 368 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!("foo'bar", *value); |
| 369 | } else { |
| 370 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected string, got null."; |
| 371 | } |
| 372 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | TESTcxx . . $ `src/kj/compat/gtest.h:120:9`!(CharParsers, SingleQuotedString) { |
| 377 | constexpr auto parser = singleQuotedStringcxx . . $ kj/parse/singleQuotedString.; |
| 378 | |
| 379 | { |
| 380 | StringPtrcxx . . $ kj/StringPtr# text = "\'hello\'"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 381 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 382 | Maybecxx . . $ kj/Maybe#<Stringcxx . . $ kj/String#> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 383 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 384 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!("hello", *value); |
| 385 | } else { |
| 386 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected \"hello\", got null."; |
| 387 | } |
| 388 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 389 | } |
| 390 | |
| 391 | { |
| 392 | StringPtrcxx . . $ kj/StringPtr# text = "\'test\\a\\b\\f\\n\\r\\t\\v\\\'\\\"\\\?\x01\2\34\156\'"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 393 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 394 | Maybecxx . . $ kj/Maybe#<Stringcxx . . $ kj/String#> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 395 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 396 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!("test\a\b\f\n\r\t\v\'\"\?\x01\2\34\156", *value); |
| 397 | } else { |
| 398 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected string, got null."; |
| 399 | } |
| 400 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 401 | } |
| 402 | |
| 403 | { |
| 404 | StringPtrcxx . . $ kj/StringPtr# text = "\'foo\"bar\'"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).; |
| 405 | Inputcxx . . $ kj/parse/`$anonymous_namespace_src/kj/parse/char-test.c++`/Input# inputcxx . . $ kj/parse/IteratorInput#IteratorInput(f4f29097f76b2f45).(text.begincxx . . $ kj/StringPtr#begin(a9f41ea0e82d88cf).(), text.endcxx . . $ kj/StringPtr#end(a9f41ea0e82d88cf).()); |
| 406 | Maybecxx . . $ kj/Maybe#<Stringcxx . . $ kj/String#> result = parser(cxx . . $ kj/parse/Transform_#`operator()`(eeee4b5ead0a75bc).input); |
| 407 | KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(value, result) { |
| 408 | EXPECT_EQcxx . . $ `src/kj/compat/gtest.h:56:9`!("foo\"bar", *value); |
| 409 | } else { |
| 410 | ADD_FAILUREcxx . . $ `src/kj/compat/gtest.h:101:9`!() <<cxx . . $ kj/AddFailureAdapter#`operator<<`(fe7a8a4d1eddb70). "Expected string, got null."; |
| 411 | } |
| 412 | EXPECT_TRUEcxx . . $ `src/kj/compat/gtest.h:55:9`!(input.atEnd()); |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | } // namespace |
| 417 | } // namespace parse |
| 418 | } // namespace kj |