Skip to content

Commit

Permalink
Тесты
Browse files Browse the repository at this point in the history
  • Loading branch information
dmpas committed May 15, 2018
1 parent 2c54697 commit 2a67ab4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/tests/SystemClasses/test_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,20 @@ TEST_CASE("Конвертация строк", "[SystemClasses][String][Encoding
}
}
}

TEST_CASE("Конвертация строк UTF-16", "[SystemClasses][String][Encoding]")
{
GIVEN( "Строка u'dc0a6b43-5503-11e8-9479-cdce35f4f3fd'" ) {
const char16_t *str = u"dc0a6b43-5503-11e8-9479-cdce35f4f3fd";
const int LEN = 36 * sizeof(char16_t);
WHEN ("Вызываем Unicode->toUtf8()" ) {
vector<uint8_t> data;
const uint8_t *casted = reinterpret_cast<const uint8_t *> (str);
data.assign(casted, casted + LEN);
string result = System::Sysutils::TEncoding::Unicode->toUtf8(data);
THEN ( "Получаем строку 'dc0a6b43-5503-11e8-9479-cdce35f4f3fd'" ) {
REQUIRE (result == "dc0a6b43-5503-11e8-9479-cdce35f4f3fd");
}
}
}
}
37 changes: 37 additions & 0 deletions src/tests/tool1cd/test_binaryguid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
test_project provides tests for Tool1CD library
Copyright © 2009-2017 awa
Copyright © 2017-2018 E8 Tools contributors
This file is part of test_project.
test_project is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
test_project is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with test_project. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../catch.hpp"
#include "BinaryGuid.h"
#include <SystemClasses/String.hpp>

TEST_CASE( "Проверка работы BinaryGuid", "[tool1cd][lib][BinaryGuid]" ) {

GIVEN ("Строка 'dc0a6b43-5503-11e8-9479-cdce35f4f3fd'") {
std::string data = "dc0a6b43-5503-11e8-9479-cdce35f4f3fd";
WHEN ("Создаём BinaryGuid") {
BinaryGuid guid(data);
THEN("строковое представление == 'dc0a6b43-5503-11e8-9479-cdce35f4f3fd'") {
REQUIRE(System::Equal(guid.as_1C(), data));
}
}
}
}

0 comments on commit 2a67ab4

Please sign in to comment.