39 CHECK(SymbolManager::parseValue<uint16_t>(
"0xa1") == 0xa1);
40 CHECK(SymbolManager::parseValue<uint32_t>(
"0xa1") == 0xa1);
41 CHECK(SymbolManager::parseValue<uint16_t>(
"0x1234") == 0x1234);
42 CHECK(SymbolManager::parseValue<uint32_t>(
"0x1234") == 0x1234);
43 CHECK(SymbolManager::parseValue<uint16_t>(
"0XABCD") == 0xabcd);
44 CHECK(SymbolManager::parseValue<uint32_t>(
"0XABCD") == 0xabcd);
45 CHECK(SymbolManager::parseValue<uint16_t>(
"0x00002345") == 0x2345);
46 CHECK(SymbolManager::parseValue<uint32_t>(
"0x00002345") == 0x2345);
47 CHECK(SymbolManager::parseValue<uint16_t>(
"$fedc") == 0xfedc);
48 CHECK(SymbolManager::parseValue<uint32_t>(
"$fedc") == 0xfedc);
49 CHECK(SymbolManager::parseValue<uint16_t>(
"#11aA") == 0x11aa);
50 CHECK(SymbolManager::parseValue<uint32_t>(
"#11aA") == 0x11aa);
51 CHECK(SymbolManager::parseValue<uint16_t>(
"bbffh") == 0xbbff);
52 CHECK(SymbolManager::parseValue<uint32_t>(
"bbffh") == 0xbbff);
53 CHECK(SymbolManager::parseValue<uint16_t>(
"3210H") == 0x3210);
54 CHECK(SymbolManager::parseValue<uint32_t>(
"3210H") == 0x3210);
55 CHECK(SymbolManager::parseValue<uint16_t>(
"01234h") == 0x1234);
56 CHECK(SymbolManager::parseValue<uint32_t>(
"01234h") == 0x1234);
58 CHECK(SymbolManager::parseValue<uint16_t>(
"123") == 0x007b);
59 CHECK(SymbolManager::parseValue<uint32_t>(
"123") == 0x007b);
60 CHECK(SymbolManager::parseValue<uint16_t>(
"65535") == 0xffff);
61 CHECK(SymbolManager::parseValue<uint32_t>(
"65535") == 0xffff);
62 CHECK(SymbolManager::parseValue<uint16_t>(
"0020") == 0x0014);
63 CHECK(SymbolManager::parseValue<uint32_t>(
"0020") == 0x0014);
65 CHECK(SymbolManager::parseValue<uint16_t>(
"%1100") == 0x000c);
66 CHECK(SymbolManager::parseValue<uint32_t>(
"%1100") == 0x000c);
67 CHECK(SymbolManager::parseValue<uint16_t>(
"0b000100100011") == 0x0123);
68 CHECK(SymbolManager::parseValue<uint32_t>(
"0b000100100011") == 0x0123);
69 CHECK(SymbolManager::parseValue<uint16_t>(
"0B1111000001011000") == 0xf058);
70 CHECK(SymbolManager::parseValue<uint32_t>(
"0B1111000001011000") == 0xf058);
74 CHECK(SymbolManager::parseValue<uint16_t>(
"0xFEDX") == std::nullopt);
75 CHECK(SymbolManager::parseValue<uint32_t>(
"0xFEDGFF") == std::nullopt);
76 CHECK(SymbolManager::parseValue<uint16_t>(
"1234a") == std::nullopt);
77 CHECK(SymbolManager::parseValue<uint32_t>(
"1234567a") == std::nullopt);
78 CHECK(SymbolManager::parseValue<uint16_t>(
"-3") == std::nullopt);
79 CHECK(SymbolManager::parseValue<uint32_t>(
"-100000") == std::nullopt);
80 CHECK(SymbolManager::parseValue<uint16_t>(
"0b00112110") == std::nullopt);
81 CHECK(SymbolManager::parseValue<uint32_t>(
"0b00110113") == std::nullopt);
83 CHECK(SymbolManager::parseValue<uint16_t>(
"0x10000") == std::nullopt);
84 CHECK(SymbolManager::parseValue<uint16_t>(
"65536") == std::nullopt);
85 CHECK(SymbolManager::parseValue<uint16_t>(
"%11110000111100001") == std::nullopt);
86 CHECK(SymbolManager::parseValue<uint32_t>(
"0x100000000") == std::nullopt);
87 CHECK(SymbolManager::parseValue<uint32_t>(
"4294967296") == std::nullopt);
88 CHECK(SymbolManager::parseValue<uint32_t>(
"%111100001111000011110000111100001") == std::nullopt);
119 SECTION(
"on extension") {
120 std::string_view buffer =
"content doesn't matter";
129 SECTION(
".sym extension") {
141 auto dummyParser = [](std::span<std::string_view> tokens) -> std::optional<Symbol> {
142 if (tokens.size() == 1)
return Symbol{std::string(tokens[0]), 123, {}, {}};
146 SECTION(
"empty file") {
147 std::string_view buffer;
149 CHECK(file.filename ==
"file.sym");
150 CHECK(file.type == SymbolFile::Type::GENERIC);
151 CHECK(file.symbols.empty());
153 SECTION(
"comment + symbol") {
154 std::string_view buffer =
155 "; This is a comment\n"
158 "bar ; comment on same line\n";
160 CHECK(file.filename ==
"file2.sym");
161 CHECK(file.type == SymbolFile::Type::NOICE);
162 REQUIRE(file.symbols.size() == 2);
163 CHECK(file.symbols[0].name ==
"bla");
164 CHECK(file.symbols[0].value == 123);
165 CHECK(file.symbols[1].name ==
"bar");
166 CHECK(file.symbols[1].value == 123);
193 std::string_view buffer =
195 "def bar 234h ; comment\n"
197 "def error 99 extra stuff\n";
199 CHECK(file.filename ==
"noice.sym");
200 CHECK(file.type == SymbolFile::Type::NOICE);
201 REQUIRE(file.symbols.size() == 2);
202 CHECK(file.symbols[0].name ==
"foo");
203 CHECK(file.symbols[0].value == 1);
204 CHECK(file.symbols[0].segment == std::nullopt);
205 CHECK(file.symbols[1].name ==
"bar");
206 CHECK(file.symbols[1].value == 0x234);
207 CHECK(file.symbols[1].segment == std::nullopt);
212 std::string_view buffer =
214 "def bar 234h ; comment\n"
216 "def error 99 extra stuff\n"
217 "def baz 123456h ; comment\n";
219 CHECK(file.filename ==
"noice.sym");
220 CHECK(file.type == SymbolFile::Type::NOICE);
221 REQUIRE(file.symbols.size() == 3);
222 CHECK(file.symbols[0].name ==
"foo");
223 CHECK(file.symbols[0].value == 1);
224 CHECK(file.symbols[0].segment == 0);
225 CHECK(file.symbols[1].name ==
"bar");
226 CHECK(file.symbols[1].value == 0x234);
227 CHECK(file.symbols[1].segment == 0);
228 CHECK(file.symbols[2].name ==
"baz");
229 CHECK(file.symbols[2].value == 0x3456);
230 CHECK(file.symbols[2].segment == 0x12);
282 std::string_view buffer =
283 "ignore1 text 2CE7 ignore2 0AEE\n"
284 "ignore3 2E58 ignore3 text 2E4C\n"
286 "asllmod text 2CE7 asllsub 0AEE\n"
287 "cret 2E58 csv text 2E4C\n"
291 CHECK(file.filename ==
"link.map");
292 CHECK(file.type == SymbolFile::Type::LINKMAP);
293 REQUIRE(file.symbols.size() == 6);
294 CHECK(file.symbols[0].name ==
"asllmod");
295 CHECK(file.symbols[0].value == 0x2ce7);
296 CHECK(file.symbols[1].name ==
"asllsub");
297 CHECK(file.symbols[1].value == 0x0aee);
298 CHECK(file.symbols[2].name ==
"cret");
299 CHECK(file.symbols[2].value == 0x2e58);
300 CHECK(file.symbols[3].name ==
"csv");
301 CHECK(file.symbols[3].value == 0x2e4c);
302 CHECK(file.symbols[4].name ==
"single");
303 CHECK(file.symbols[4].value == 0x9876);
304 CHECK(file.symbols[5].name ==
"last");
305 CHECK(file.symbols[5].value == 0x8765);