feat: add current_exe in rust env
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/rust/env.hpp>
|
||||
#include <yycc/macro/os_detector.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#define ENV ::yycc::rust::env
|
||||
|
||||
@ -9,7 +11,7 @@ namespace yycctest::rust::env {
|
||||
constexpr char8_t VAR_NAME[] = u8"HOMER";
|
||||
constexpr char8_t VAR_VALUE[] = u8"doh";
|
||||
|
||||
TEST(RustEnv, All) {
|
||||
TEST(RustEnv, EnvVar) {
|
||||
// Write a new variable should okey
|
||||
{
|
||||
auto rv = ENV::set_var(VAR_NAME, VAR_VALUE);
|
||||
@ -42,4 +44,19 @@ namespace yycctest::rust::env {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
TEST(RustEnv, CurrentExe) {
|
||||
auto rv = ENV::current_exe();
|
||||
ASSERT_TRUE(rv.has_value());
|
||||
|
||||
std::filesystem::path p(rv.value());
|
||||
auto filename = p.filename().u8string();
|
||||
#if defined(YYCC_OS_WINDOWS)
|
||||
// Only Windows has special ext.
|
||||
EXPECT_EQ(filename, u8"YYCCTest.exe");
|
||||
#else
|
||||
// Executable in other system are all in plain name.
|
||||
EXPECT_EQ(filename, u8"YYCCTest");
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace yycctest::rust::env
|
||||
|
Reference in New Issue
Block a user