Release Readt
Some checks failed
CI / build-linux-and-wasm (x64-linux) (push) Has been cancelled

This commit is contained in:
2026-01-25 22:08:16 +05:30
parent 601b573983
commit ebde7c7e66
19 changed files with 51 additions and 567 deletions

View File

@ -18,22 +18,14 @@
using namespace IACore;
// -----------------------------------------------------------------------------
// Test Block Definition
// -----------------------------------------------------------------------------
IAT_BEGIN_BLOCK(Core, CLI)
// -------------------------------------------------------------------------
// 1. Basic Traversal
// -------------------------------------------------------------------------
auto test_basic_traversal() -> bool {
const Vec<String> args = {"ignored", "one", "two", "three"};
CLIParser parser(args);
IAT_CHECK(parser.remaining());
// Check sequential access
IAT_CHECK_EQ(String(parser.next()), "one");
IAT_CHECK(parser.remaining());
@ -42,30 +34,22 @@ auto test_basic_traversal() -> bool {
IAT_CHECK_EQ(String(parser.next()), "three");
// Should be exhausted now
IAT_CHECK_NOT(parser.remaining());
// Next on exhausted returns empty string view
IAT_CHECK_EQ(String(parser.next()), "");
return true;
}
// -------------------------------------------------------------------------
// 2. Peek Functionality
// -------------------------------------------------------------------------
auto test_peek() -> bool {
const Vec<String> args = {"ignored", "peek_val", "next_val"};
CLIParser parser(args);
// Peek should return value but not advance
IAT_CHECK_EQ(String(parser.peek()), "peek_val");
IAT_CHECK(parser.remaining());
// Verify we are still at the same element
IAT_CHECK_EQ(String(parser.next()), "peek_val");
// Now we should be at next_val
IAT_CHECK_EQ(String(parser.peek()), "next_val");
IAT_CHECK_EQ(String(parser.next()), "next_val");
@ -74,29 +58,20 @@ auto test_peek() -> bool {
return true;
}
// -------------------------------------------------------------------------
// 3. Consume Functionality
// -------------------------------------------------------------------------
auto test_consume() -> bool {
const Vec<String> args = {"ignored", "-v", "--output", "file.txt"};
CLIParser parser(args);
// 1. Try consuming something that isn't there
IAT_CHECK_NOT(parser.consume("-x"));
// Verify we haven't moved
IAT_CHECK_EQ(String(parser.peek()), "-v");
// 2. Consume the correct flag
IAT_CHECK(parser.consume("-v"));
// 3. Verify advancement
IAT_CHECK_EQ(String(parser.peek()), "--output");
// 4. Consume next
IAT_CHECK(parser.consume("--output"));
// 5. Verify final argument
IAT_CHECK_EQ(String(parser.next()), "file.txt");
IAT_CHECK_NOT(parser.remaining());
@ -104,9 +79,6 @@ auto test_consume() -> bool {
return true;
}
// -------------------------------------------------------------------------
// 4. Empty Argument List
// -------------------------------------------------------------------------
auto test_empty() -> bool {
const Vec<String> args = {};
CLIParser parser(args);
@ -119,9 +91,6 @@ auto test_empty() -> bool {
return true;
}
// -------------------------------------------------------------------------
// Registration
// -------------------------------------------------------------------------
IAT_BEGIN_TEST_LIST()
IAT_ADD_TEST(test_basic_traversal);
IAT_ADD_TEST(test_peek);