mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-08 18:05:32 +00:00
chore(developer): moved CompMsg.cpp refactor to fix #11738
This commit is contained in:
parent
1dc6ebf2cb
commit
8dde071b89
3 changed files with 15 additions and 35 deletions
|
|
@ -1,7 +1,11 @@
|
|||
#include <CompMsg.h>
|
||||
#include <map>
|
||||
|
||||
std::map<KMX_DWORD, const KMX_CHAR*> CompilerErrorMap = {
|
||||
struct CompilerError {
|
||||
KMX_DWORD ErrorCode;
|
||||
const KMX_CHAR* Text;
|
||||
};
|
||||
|
||||
const struct CompilerError CompilerErrors[] = {
|
||||
{ CERR_InvalidLayoutLine , "Invalid 'layout' command"},
|
||||
{ CERR_NoVersionLine , "No version line found for file"},
|
||||
{ CERR_InvalidGroupLine , "Invalid 'group' command"},
|
||||
|
|
@ -146,8 +150,14 @@ std::map<KMX_DWORD, const KMX_CHAR*> CompilerErrorMap = {
|
|||
{ CWARN_VirtualKeyInOutput , "Virtual keys are not supported in output"},
|
||||
|
||||
{ 0, nullptr }
|
||||
};
|
||||
};
|
||||
|
||||
KMX_CHAR *GetCompilerErrorString(KMX_DWORD code) {
|
||||
return (KMX_CHAR*) CompilerErrorMap[code];
|
||||
KMX_CHAR *GetCompilerErrorString(KMX_DWORD code)
|
||||
{
|
||||
for(int i = 0; CompilerErrors[i].ErrorCode; i++) {
|
||||
if(CompilerErrors[i].ErrorCode == code) {
|
||||
return ( KMX_CHAR*) CompilerErrors[i].Text;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include "..\..\common\include\kmn_compiler_errors.h"
|
||||
#include "..\..\..\..\common\include\km_types.h"
|
||||
|
||||
KMX_CHAR *GetCompilerErrorString(KMX_DWORD code);
|
||||
|
||||
class CompMsgTest : public testing::Test {
|
||||
protected:
|
||||
CompMsgTest() {}
|
||||
~CompMsgTest() override {}
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
TEST_F(CompMsgTest, GetCompilerErrorString) {
|
||||
EXPECT_EQ(nullptr, GetCompilerErrorString(CERR_None));
|
||||
EXPECT_EQ(nullptr, GetCompilerErrorString(0x00004FFF)); // top of range ERROR
|
||||
EXPECT_EQ("Invalid 'layout' command", GetCompilerErrorString(CERR_InvalidLayoutLine));
|
||||
};
|
||||
|
|
@ -167,14 +167,3 @@ gtestcompilertest = executable('gtest-compiler-test', 'gtest-compiler-test.cpp',
|
|||
)
|
||||
|
||||
test('gtest-compiler-test', gtestcompilertest)
|
||||
|
||||
gtestcompmsgtest = executable('gtest-compmsg-test', 'gtest-compmsg-test.cpp',
|
||||
cpp_args: defns + flags,
|
||||
include_directories: inc,
|
||||
name_suffix: name_suffix,
|
||||
link_args: links + tests_links,
|
||||
objects: lib.extract_all_objects(),
|
||||
dependencies: [ icuuc_dep, gtest_dep, gmock_dep ],
|
||||
)
|
||||
|
||||
test('gtest-compmsg-test', gtestcompmsgtest)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue