Commit d37e927c authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Added sorting test for optional class

parent fe3133db
......@@ -20,6 +20,7 @@
#include <gtest/gtest.h>
#include <string>
#include <algorithm>
namespace unitTests {
......@@ -206,5 +207,27 @@ TEST_F(cta_optionalTest, comparisons) {
ASSERT_TRUE(o1 >= nullopt);
}
TEST_F(cta_optionalTest, sort) {
using namespace cta;
std::vector<optional<std::string>> v;
v.push_back(std::string("Hobgoblin"));
v.push_back(std::string("Aquator"));
v.push_back(std::string("Griffin"));
v.push_back(std::string("Ice monster"));
v.push_back(std::string("Centaur"));
v.push_back(nullopt);
v.push_back(std::string("Emu"));
v.push_back(std::string("Venus Fly Trap"));
v.push_back(std::string("Bat"));
v.push_back(std::string("Dragon"));
ASSERT_NO_THROW(std::sort(v.begin(), v.end()));
ASSERT_TRUE(v.front()==nullopt);
ASSERT_TRUE(v.back()==std::string("Venus Fly Trap"));
}
} // namespace unitTests
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment