From 9e972b64c1775c351ef8670937016054ee1f9ab3 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 16 Feb 2022 10:12:08 +0800 Subject: [PATCH] Huawei CodeCheck // Remove Mandarin Tests. --- Source/Modules/Mandarin/CMakeLists.txt | 31 ------ Source/Modules/Mandarin/MandarinTest.cpp | 120 ----------------------- 2 files changed, 151 deletions(-) delete mode 100644 Source/Modules/Mandarin/CMakeLists.txt delete mode 100644 Source/Modules/Mandarin/MandarinTest.cpp diff --git a/Source/Modules/Mandarin/CMakeLists.txt b/Source/Modules/Mandarin/CMakeLists.txt deleted file mode 100644 index fbfedea2..00000000 --- a/Source/Modules/Mandarin/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.17) -project(Mandarin) - -set(CMAKE_CXX_STANDARD 17) - -add_library(MandarinLib Mandarin.h Mandarin.cpp) - -# Let CMake fetch Google Test for us. -# https://github.com/google/googletest/tree/main/googletest#incorporating-into-an-existing-cmake-project -include(FetchContent) - -FetchContent_Declare( - googletest - # Specify the commit you depend on and update it regularly. - URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip -) -# For Windows: Prevent overriding the parent project's compiler/linker settings -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(googletest) - -# Test target declarations. -add_executable(MandarinTest MandarinTest.cpp) -target_link_libraries(MandarinTest gtest_main MandarinLib) -include(GoogleTest) -gtest_discover_tests(MandarinTest) - -add_custom_target( - runTest - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/MandarinTest -) -add_dependencies(runTest MandarinTest) diff --git a/Source/Modules/Mandarin/MandarinTest.cpp b/Source/Modules/Mandarin/MandarinTest.cpp deleted file mode 100644 index 3ee48580..00000000 --- a/Source/Modules/Mandarin/MandarinTest.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2022 and onwards Lukhnos Liu -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -#include "Mandarin.h" -#include "gtest/gtest.h" - -namespace Formosa { -namespace Mandarin { - -static std::string RoundTrip(const std::string& composedString) { - return BopomofoSyllable::FromComposedString(composedString).composedString(); -} - -TEST(MandarinTest, FromComposedString) { - ASSERT_EQ(RoundTrip("ㄅ"), "ㄅ"); - ASSERT_EQ(RoundTrip("ㄅㄧ"), "ㄅㄧ"); - ASSERT_EQ(RoundTrip("ㄅㄧˇ"), "ㄅㄧˇ"); - ASSERT_EQ(RoundTrip("ㄅㄧˇㄆ"), "ㄆㄧˇ"); - ASSERT_EQ(RoundTrip("ㄅㄧˇㄆ"), "ㄆㄧˇ"); - ASSERT_EQ(RoundTrip("e"), ""); - ASSERT_EQ(RoundTrip("é"), ""); - ASSERT_EQ(RoundTrip("ㄅéㄆ"), "ㄅ"); - ASSERT_EQ(RoundTrip("ㄅeㄆ"), "ㄅ"); -} - -TEST(MandarinTest, SimpleCompositions) { - BopomofoSyllable syllable; - syllable += BopomofoSyllable(BopomofoSyllable::X); - syllable += BopomofoSyllable(BopomofoSyllable::I); - ASSERT_EQ(syllable.composedString(), "ㄒㄧ"); - - syllable.clear(); - syllable += BopomofoSyllable(BopomofoSyllable::Z); - syllable += BopomofoSyllable(BopomofoSyllable::ANG); - syllable += BopomofoSyllable(BopomofoSyllable::Tone4); - ASSERT_EQ(syllable.composedString(), "ㄗㄤˋ"); -} - -TEST(MandarinTest, StandardLayout) { - BopomofoReadingBuffer buf(BopomofoKeyboardLayout::StandardLayout()); - buf.combineKey('w'); - buf.combineKey('9'); - buf.combineKey('6'); - ASSERT_EQ(buf.composedString(), "ㄊㄞˊ"); -} - -TEST(MandarinTest, StandardLayoutCombination) { - BopomofoReadingBuffer buf(BopomofoKeyboardLayout::StandardLayout()); - buf.combineKey('w'); - buf.combineKey('9'); - buf.combineKey('6'); - ASSERT_EQ(buf.composedString(), "ㄊㄞˊ"); - - buf.backspace(); - ASSERT_EQ(buf.composedString(), "ㄊㄞ"); - - buf.combineKey('y'); - ASSERT_EQ(buf.composedString(), "ㄗㄞ"); - - buf.combineKey('4'); - ASSERT_EQ(buf.composedString(), "ㄗㄞˋ"); - - buf.combineKey('3'); - ASSERT_EQ(buf.composedString(), "ㄗㄞˇ"); -} - -TEST(MandarinTest, ETenLayout) { - BopomofoReadingBuffer buf(BopomofoKeyboardLayout::ETenLayout()); - buf.combineKey('x'); - buf.combineKey('8'); - ASSERT_EQ(buf.composedString(), "ㄨㄢ"); -} - -TEST(MandarinTest, ETen26Layout) { - BopomofoReadingBuffer buf(BopomofoKeyboardLayout::ETen26Layout()); - buf.combineKey('q'); - buf.combineKey('m'); // AN in the vowel state - buf.combineKey('k'); // Tone 4 in the tone state - ASSERT_EQ(buf.composedString(), "ㄗㄢˋ"); -} - -TEST(MandarinTest, HsuLayout) { - BopomofoReadingBuffer buf(BopomofoKeyboardLayout::HsuLayout()); - buf.combineKey('f'); - buf.combineKey('a'); // EI when in the vowel state - buf.combineKey('f'); // Tone 3 when in the tone state - ASSERT_EQ(buf.composedString(), "ㄈㄟˇ"); -} - -TEST(MandarinTest, IBMLayout) { - BopomofoReadingBuffer buf(BopomofoKeyboardLayout::IBMLayout()); - buf.combineKey('9'); - buf.combineKey('s'); - buf.combineKey('g'); - buf.combineKey('m'); - ASSERT_EQ(buf.composedString(), "ㄍㄨㄛˊ"); -} - -} // namespace Mandarin -} // namespace Formosa