mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
ci: fix name of directory and add test script
This commit is contained in:
@@ -7,7 +7,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run: g++ --version
|
- run: g++ --version
|
||||||
- run: cd test/
|
- run: cd tests/
|
||||||
- run: g++ -std=c++11 -O2 -Wall -Wextra -Werror check.cpp -o check
|
- run: g++ -std=c++11 -O2 -Wall -Wextra -Werror check.cpp -o check
|
||||||
- run: git clone https://github.com/BurntSushi/toml-test.git
|
- run: git clone https://github.com/BurntSushi/toml-test.git
|
||||||
- run: cp check toml-test/tests/invalid
|
- run: cp check toml-test/tests/invalid
|
||||||
|
41
tests/check.cpp
Normal file
41
tests/check.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include "toml.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if(argc != 3)
|
||||||
|
{
|
||||||
|
std::cerr << "usage: ./check [filename] [valid|invalid]" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string file_kind(argv[2]);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto data = toml::parse(argv[1]);
|
||||||
|
std::cout << std::setprecision(16) << std::setw(80) << data;
|
||||||
|
if(file_kind == "valid")
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(const toml::syntax_error& err)
|
||||||
|
{
|
||||||
|
std::cout << "what(): " << err.what() << std::endl;
|
||||||
|
if(file_kind == "invalid")
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 127;
|
||||||
|
}
|
Reference in New Issue
Block a user