diff options
author | Sergey Magidovich <mgsergio@mapswithme.com> | 2016-03-11 17:34:10 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:56:28 +0300 |
commit | 9cec925752462dd806bce66c2c8cbff6e9144666 (patch) | |
tree | 6e779e374d4f782b7c616ae0ed6ae3f3aedd4764 /editor/editor_tests | |
parent | f9e8c97c6fb55926ff906e0320cf68c618dc02a3 (diff) |
Code review. Fix data loss.
Diffstat (limited to 'editor/editor_tests')
-rw-r--r-- | editor/editor_tests/editor_notes_test.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/editor/editor_tests/editor_notes_test.cpp b/editor/editor_tests/editor_notes_test.cpp index a2e4ad6736..80845ccc59 100644 --- a/editor/editor_tests/editor_notes_test.cpp +++ b/editor/editor_tests/editor_notes_test.cpp @@ -2,39 +2,41 @@ #include "editor/editor_notes.hpp" +#include "geometry/mercator.hpp" + #include "platform/platform_tests_support/scoped_file.hpp" -using namespace editor; +#include "coding/file_name_utils.hpp" -namespace editor -{ -string DebugPrint(Note const & note) -{ - return "Note(" + DebugPrint(note.m_point) + ", \"" + note.m_note + "\")"; -} -} // namespace editor +#include "base/math.hpp" + +using namespace editor; -UNIT_TEST(Notes) +UNIT_TEST(Notes_Smoke) { auto const fileName = "notes.xml"; - auto const fullFileName = Platform::PathJoin({GetPlatform().WritableDir(), - fileName}); + auto const fullFileName = my::JoinFoldersToPath({GetPlatform().WritableDir()}, fileName); platform::tests_support::ScopedFile sf(fileName); { - auto const notes = Notes::MakeNotes(fullFileName); + auto const notes = Notes::MakeNotes(fullFileName, true); notes->CreateNote({1, 2}, "Some note1"); notes->CreateNote({2, 2}, "Some note2"); notes->CreateNote({1, 1}, "Some note3"); } { - auto const notes = Notes::MakeNotes(fullFileName); + auto const notes = Notes::MakeNotes(fullFileName, true); auto const result = notes->GetNotes(); TEST_EQUAL(result.size(), 3, ()); - TEST_EQUAL(result, - (vector<Note>{ - {{1, 2}, "Some note1"}, - {{2, 2}, "Some note2"}, - {{1, 1}, "Some note3"} - }), ()); + vector<Note> const expected { + {MercatorBounds::ToLatLon({1, 2}), "Some note1"}, + {MercatorBounds::ToLatLon({2, 2}), "Some note2"}, + {MercatorBounds::ToLatLon({1, 1}), "Some note3"} + }; + for (auto i = 0; i < result.size(); ++i) + { + TEST(my::AlmostEqualAbs(result[i].m_point.lat, expected[i].m_point.lat, 1e-7), ()); + TEST(my::AlmostEqualAbs(result[i].m_point.lon, expected[i].m_point.lon, 1e-7), ()); + TEST_EQUAL(result[i].m_note, expected[i].m_note, ()); + } } } |