mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[upstream_utils] Import argparse to wpiutil (#7071)
This commit is contained in:
18
wpiutil/src/test/native/cpp/argparse/ArgumentParserTest.cpp
Normal file
18
wpiutil/src/test/native/cpp/argparse/ArgumentParserTest.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user