blob: 6245259b9ee31508cf82f0a6c0ba4aeed445bab3 [file] [log] [blame]
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <flasher/mod.hpp>
#include <gtest/gtest.h>
namespace flasher
{
TEST(ModArgs, Empty)
{
ModArgs args("");
EXPECT_TRUE(args.dict.empty());
EXPECT_EQ(args.arr, std::vector<std::string>{""});
}
TEST(ModArgs, Simple)
{
ModArgs args("abcd");
EXPECT_TRUE(args.dict.empty());
EXPECT_EQ(args.arr, std::vector<std::string>{"abcd"});
}
TEST(ModArgs, MultiArgs)
{
ModArgs args(",a1,a=b,a\\=b,c\\,d,hi=/no-such-path,");
EXPECT_EQ(args.dict, (std::unordered_map<std::string, std::string>{
{"a", "b"}, {"hi", "/no-such-path"}}));
EXPECT_EQ(args.arr, (std::vector<std::string>{"", "a1", "a=b", "c,d", ""}));
}
} // namespace flasher