-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc32473
commit fb6e45b
Showing
8 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[wrap-file] | ||
directory = googletest-release-1.10.0 | ||
|
||
source_url = https://github.com/google/googletest/archive/release-1.10.0.zip | ||
source_filename = gtest-1.10.0.zip | ||
source_hash = 94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91 | ||
|
||
patch_url = https://wrapdb.mesonbuild.com/v1/projects/gtest/1.10.0/1/get_zip | ||
patch_filename = gtest-1.10.0-1-wrap.zip | ||
patch_hash = 04ff14e8880e4e465f6260221e9dfd56fea6bc7cce4c4aff0dc528e4a2c8f514 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdio.h> | ||
#include <gtest/gtest.h> | ||
#include "util_tests.hpp" | ||
#include "true_env_info.h" | ||
|
||
int main(int argc, char* argv[]) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
printf("true_env_info.h:\n"); | ||
printf(" build dir: %s\n", TRUE_BUILD_DIR); | ||
printf(" exe path: %s\n", TRUE_EXE_PATH); | ||
printf(" cwd: %s\n", TRUE_CWD); | ||
printf(" os: %s\n", TRUE_OS); | ||
return RUN_ALL_TESTS(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
if meson.is_cross_build() | ||
error('unit tests does NOT support cross build.') | ||
endif | ||
|
||
true_build_dir = meson.current_build_dir().replace('\\', '\\\\') | ||
true_source_root = meson.project_source_root().replace('\\', '\\\\') | ||
true_exe_name = 'env_utils_test' | ||
if envu_OS == 'windows' | ||
true_exe_name += '.exe' | ||
endif | ||
|
||
test_conf = configuration_data() | ||
test_conf.set('BUILD_DIR', true_build_dir) | ||
test_conf.set('SOURCE_ROOT', true_source_root) | ||
test_conf.set('EXE_NAME', true_exe_name) | ||
test_conf.set('OS', envu_OS) | ||
configure_file(input : 'true_env_info.h.in', | ||
output : 'true_env_info.h', | ||
configuration : test_conf) | ||
|
||
test_exe = executable('env_utils_test', | ||
'main.cpp', | ||
dependencies : [env_utils_dep, gtest_dep, gmock_dep], | ||
install : false) | ||
|
||
test('env_utils_test', test_exe, workdir: true_source_root) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
const char *TRUE_BUILD_DIR = "@BUILD_DIR@"; | ||
const char *TRUE_EXE_PATH = "@BUILD_DIR@\\\\@EXE_NAME@"; | ||
const char *TRUE_CWD = "@SOURCE_ROOT@"; | ||
const char *TRUE_OS = "@OS@"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
#include <gtest/gtest.h> | ||
#include "env_utils.h" | ||
#include "true_env_info.h" | ||
#include <algorithm> | ||
#include <cctype> | ||
#include <string> | ||
|
||
TEST(UtilTest, envuGetVersion) { | ||
ASSERT_STREQ(ENVU_VERSION, envuGetVersion()); | ||
} | ||
|
||
TEST(UtilTest, envuGetVersionInt) { | ||
ASSERT_EQ(ENVU_VERSION_INT, envuGetVersionAsInt()); | ||
} | ||
|
||
TEST(UtilTest, envuGetOS) { | ||
char* os = envuGetOS(); | ||
std::string os_lower(os); | ||
std::transform(os_lower.begin(), os_lower.end(), os_lower.begin(), | ||
[](unsigned char c){ return std::tolower(c); }); | ||
envuFree(os); | ||
ASSERT_STREQ(TRUE_OS, os_lower.c_str()); | ||
} | ||
|
||
TEST(UtilTest, envuGetExecutablePath) { | ||
char* exe_path = envuGetExecutablePath(); | ||
ASSERT_STREQ(TRUE_EXE_PATH, exe_path); | ||
envuFree(exe_path); | ||
} | ||
|
||
TEST(UtilTest, envuGetExecutableDir) { | ||
char* exe_dir = envuGetExecutableDir(); | ||
ASSERT_STREQ(TRUE_BUILD_DIR, exe_dir); | ||
envuFree(exe_dir); | ||
} | ||
|
||
TEST(UtilTest, envuGetCwd) { | ||
char* cwd = envuGetCwd(); | ||
ASSERT_STREQ(TRUE_CWD, cwd); | ||
envuFree(cwd); | ||
} |