From e6e2c5a8bf5c99119799c9ac706c4428fec6b5aa Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Mon, 24 Jan 2022 16:41:02 +0100 Subject: Improve tests --- src/pgnp.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/pgnp.cpp') diff --git a/src/pgnp.cpp b/src/pgnp.cpp index bb9fd29..5336cd6 100644 --- a/src/pgnp.cpp +++ b/src/pgnp.cpp @@ -239,7 +239,12 @@ int PGN::ParseNextTag(int start_loc) { tags[key] = value; tagkeys.push_back(key); - // TODO: Check that caracters if a ] + EOF_CHECK(valueloc + 1); + c = pgn_content[valueloc + 1]; + if (c != ']') { + throw UnexpectedCharacter(c, ']', valueloc + 1); + } + return (valueloc + 1); // +1 For the last char of the tag which is ']' } @@ -247,7 +252,12 @@ HalfMove *PGN::GetMoves() { return (moves); } std::vector PGN::GetTagList() { return tagkeys; } -std::string PGN::GetTagValue(std::string key) { return tags[key]; } +std::string PGN::GetTagValue(std::string key) { + if (tags.find(key) == tags.end()) { + throw InvalidTagName(); + } + return tags[key]; +} void PGN::Dump() { std::cout << "---------- PGN DUMP ----------" << std::endl; -- cgit v1.2.3