diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-05-22 17:39:39 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-05-23 23:04:45 +0800 |
commit | 68c4695fdc7c2b3f73484bf03d24742034eed103 (patch) | |
tree | 183350a2955f08fc47c369c3a1fc3527de83bdb4 /test | |
parent | Walker: support ${*:x:y} expansion (diff) | |
download | libbash-68c4695fdc7c2b3f73484bf03d24742034eed103.tar.gz libbash-68c4695fdc7c2b3f73484bf03d24742034eed103.tar.bz2 libbash-68c4695fdc7c2b3f73484bf03d24742034eed103.zip |
API: allow sourcing a script before interpreting
Diffstat (limited to 'test')
-rw-r--r-- | test/api_test.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/api_test.cpp b/test/api_test.cpp index 8746a0a..e74313e 100644 --- a/test/api_test.cpp +++ b/test/api_test.cpp @@ -33,6 +33,8 @@ TEST(libbashapi, bad_path) std::vector<std::string> functions; EXPECT_THROW(libbash::interpret("not exist", variables, functions), interpreter_exception); + EXPECT_THROW(libbash::interpret("/scripts/source_true.sh", "not exist", variables, functions), + interpreter_exception); } TEST(libbashapi, illegal_script) @@ -59,3 +61,19 @@ TEST(libbashapi, legal_script) functions); EXPECT_NE(0, result); } + +TEST(libbashapi, preload) +{ + std::unordered_map<std::string, std::vector<std::string>> variables; + std::vector<std::string> functions; + int result = libbash::interpret(get_src_dir() + std::string("/scripts/source_true.sh"), + get_src_dir() + std::string("/scripts/source_true.sh"), + variables, + functions); + EXPECT_EQ(0, result); + result = libbash::interpret(get_src_dir() + std::string("/scripts/source_true.sh"), + get_src_dir() + std::string("/scripts/source_false.sh"), + variables, + functions); + EXPECT_NE(0, result); +} |