Macaulay2 Engine
Loading...
Searching...
No Matches
basics-test.cpp
Go to the documentation of this file.
1// Copyright 2012 Michael E. Stillman
2
31
32#include <cstdio>
33#include <string>
34#include <iostream>
35#include <sstream>
36#include <memory>
37#include <gtest/gtest.h>
38#include <mpfr.h>
39
40#include "buffer.hpp"
41#include "text-io.hpp"
42#include "util.hpp"
43
44bool testfcn() { return true; }
45TEST(Nothing, ideal)
46{
47 EXPECT_EQ(true, testfcn());
48 EXPECT_FALSE(!(testfcn()));
49}
50
51TEST(Buffer, make1)
52{
53 buffer o;
54 char *s = o.str();
55 // fprintf(stderr, ".[%s].\n", s);
56 int c = strcmp("", s);
57 EXPECT_EQ(c, 0);
58}
59
60TEST(Buffer, make2)
61{
62 buffer o;
63 o << "hi there";
64 char *s = o.str();
65 // fprintf(stderr, "..%s..\n", s);
66 int c = strcmp("hi there", s);
67 EXPECT_EQ(c, 0);
68}
69
70TEST(Util, m2array2stdvec)
71{
72 std::vector<int> a{1, 3, 6, 4};
74 std::vector<int> c = M2_arrayint_to_stdvector<int>(b);
75 EXPECT_EQ(a, c);
76}
77
78TEST(Util, m2arrayint_zero)
79{
80 std::vector<int> a{};
82 std::vector<int> c = M2_arrayint_to_stdvector<int>(b);
83 EXPECT_EQ(a, c);
84}
85
86TEST(Util, m2array2stdvec_big)
87{
88 std::vector<long long> a{-1453853049583, 3, 6, 4, -2};
90 std::vector<long long> c = M2_arrayint_to_stdvector<long long>(b);
91 EXPECT_FALSE(a == c);
92}
93
94TEST(Util, m2array2stdvec_check)
95{
96 std::vector<int> a{-145385, 3, 6, 4, -2};
99 EXPECT_EQ(a, c);
100}
101
102#if 0
103TEST(Util, m2strings_basic) {
104 std::vector<std::string> a {"a", "b", "c1", "d2", "e_3"};
105 M2_ArrayString b = stdvector_to_M2_ArrayString(a);
106 auto c = M2_ArrayString_to_stdvector(b);
107 EXPECT_EQ(a,c);
108}
109#endif
110
111// Local Variables:
112// compile-command: "make -C $M2BUILDDIR/Macaulay2/e/unit-tests check "
113// indent-tabs-mode: nil
114// End:
TEST(Nothing, ideal)
bool testfcn()
Append-only GC-backed byte buffer used throughout the engine for text output.
char * str()
Definition buffer.hpp:72
void size_t s
Definition m2-mem.cpp:271
Text-formatting helpers layered on buffer: bignum print, line wrapping, M2_gbTrace-gated emit.
M2_arrayint stdvector_to_M2_arrayint(const std::vector< T > &v)
Definition util.hpp:79
void M2_ArrayString_to_stdvector(M2_ArrayString strs, std::vector< std::string > &result)
Definition util.hpp:52
M2_ArrayString stdvector_to_M2_ArrayString(const std::vector< std::string > &strs)
Definition util.hpp:67
std::vector< T > M2_arrayint_to_stdvector(M2_arrayint arr)
Definition util.hpp:96
Conversion helpers between M2 boundary types and standard C++ containers.