General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

78 lines
1.0 KiB

#include "test_scaffold.h"
#include "gp/array.hpp"
#include <thread>
#include <chrono>
#include <numeric>
#include <iomanip>
#include <fstream>
struct arraysum_test : public test_scaffold {
arraysum_test() {
name = __FILE__ ":1";
}
virtual int run() {
gp::array<uint32_t, 16> test;
for(auto& elem : test)
{
elem = 12;
}
return std::accumulate(test.begin(), test.end(), 0) != 12*test.size();
}
};
append_test dummy_sd45uisd3(new arraysum_test{});
struct optional_test : public test_scaffold {
optional_test() {
name = __FILE__ ":1";
}
virtual int run() {
int res = 0;
{
gp::optional<uint32_t> test;
if(test.has_value())
{
res++;
}
test = 12;
if(test.has_value())
{
if(test.value()!=12)
{
res++;
}
}
else
{
res++;
}
}
{
gp::optional<std::ifstream> test;
if(test.has_value())
{
res++;
}
test = std::ifstream("/proc/cpuinfo");
if(!test.has_value())
{
res++;
}
}
return res;
}
};
append_test dummy_mlyusisd3(new optional_test{});