Initial Course
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#include "optional.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(Optional, SafeDivide) {
|
||||
EXPECT_DOUBLE_EQ(*cpp17::safe_divide(10, 2), 5.0);
|
||||
EXPECT_FALSE(cpp17::safe_divide(1, 0).has_value());
|
||||
}
|
||||
|
||||
TEST(Optional, FindUser) {
|
||||
EXPECT_EQ(*cpp17::find_user({"Ada", "Grace"}, "Grace"), 1U);
|
||||
}
|
||||
|
||||
TEST(Optional, FirstPositive) {
|
||||
EXPECT_EQ(*cpp17::first_positive({-1, 0, 3, 4}), 3);
|
||||
EXPECT_FALSE(cpp17::first_positive({-1, -2}).has_value());
|
||||
}
|
||||
Reference in New Issue
Block a user