[upstream_utils] Import argparse to wpiutil (#7071)

This commit is contained in:
Ryan Blue
2024-09-12 23:10:43 -04:00
committed by GitHub
parent 97c6c86f3b
commit 32252f7d6a
6 changed files with 2611 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include "wpi/argparse.h"
TEST(ArgparseTest, Basic) {
wpi::ArgumentParser program("ArgparseTest");
program.add_argument("test").help("Test argument").scan<'i', int>();
constexpr const char* args[] = {"foo", "42"};
EXPECT_NO_THROW(program.parse_args(2, args));
auto result = program.get<int>("test");
EXPECT_EQ(42, result);
}