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
44
bool
testfcn
() {
return
true
; }
45
TEST
(Nothing, ideal)
46
{
47
EXPECT_EQ(
true
,
testfcn
());
48
EXPECT_FALSE(!(
testfcn
()));
49
}
50
51
TEST
(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
60
TEST
(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
70
TEST
(Util, m2array2stdvec)
71
{
72
std::vector<int> a{1, 3, 6, 4};
73
M2_arrayint
b =
stdvector_to_M2_arrayint
(a);
74
std::vector<int> c =
M2_arrayint_to_stdvector<int>
(b);
75
EXPECT_EQ(a, c);
76
}
77
78
TEST
(Util, m2arrayint_zero)
79
{
80
std::vector<int> a{};
81
M2_arrayint
b =
stdvector_to_M2_arrayint
(a);
82
std::vector<int> c =
M2_arrayint_to_stdvector<int>
(b);
83
EXPECT_EQ(a, c);
84
}
85
86
TEST
(Util, m2array2stdvec_big)
87
{
88
std::vector<long long> a{-1453853049583, 3, 6, 4, -2};
89
M2_arrayint
b =
stdvector_to_M2_arrayint
(a);
90
std::vector<long long> c =
M2_arrayint_to_stdvector<long long>
(b);
91
EXPECT_FALSE(a == c);
92
}
93
94
TEST
(Util, m2array2stdvec_check)
95
{
96
std::vector<int> a{-145385, 3, 6, 4, -2};
97
M2_arrayint
b =
stdvector_to_M2_arrayint
(a);
98
auto
c =
M2_arrayint_to_stdvector<int>
(b);
99
EXPECT_EQ(a, c);
100
}
101
102
#if 0
103
TEST
(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
TEST(Nothing, ideal)
Definition
basics-test.cpp:45
testfcn
bool testfcn()
Definition
basics-test.cpp:44
buffer.hpp
Append-only GC-backed byte buffer used throughout the engine for text output.
M2_arrayint
buffer::str
char * str()
Definition
buffer.hpp:72
buffer
Definition
buffer.hpp:55
s
void size_t s
Definition
m2-mem.cpp:271
text-io.hpp
Text-formatting helpers layered on buffer: bignum print, line wrapping, M2_gbTrace-gated emit.
stdvector_to_M2_arrayint
M2_arrayint stdvector_to_M2_arrayint(const std::vector< T > &v)
Definition
util.hpp:79
M2_ArrayString_to_stdvector
void M2_ArrayString_to_stdvector(M2_ArrayString strs, std::vector< std::string > &result)
Definition
util.hpp:52
stdvector_to_M2_ArrayString
M2_ArrayString stdvector_to_M2_ArrayString(const std::vector< std::string > &strs)
Definition
util.hpp:67
M2_arrayint_to_stdvector
std::vector< T > M2_arrayint_to_stdvector(M2_arrayint arr)
Definition
util.hpp:96
util.hpp
Conversion helpers between M2 boundary types and standard C++ containers.
Macaulay2
e
unit-tests
basics-test.cpp
Generated on
for Macaulay2 Engine by
1.15.0