Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test for istream. #56

Merged
merged 2 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ foreach(testsourcefile ${TEST_SOURCES})
add_test(${testname} ${testname})
endforeach()

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/input.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/input.txt)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/input.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
15 changes: 1 addition & 14 deletions tests/operators/input.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
1
100
10000
100000000
10000000000000000
100000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-10000000000000000000000000
-1122178617862763873649236587264782365872467823
-149023932491
-34873298478923748973289476592365782689523657926958326459823659726598237503297598246583657924628934928357891
-26589237985678256786763278562876389472836578264892365427961
1,100,10000,100000000,10000000000000000,100000000000000000000000000000000,100000000000000000000000000000000000000000000000000000000000000000,99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999,1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-10000000000000000000000000,-1122178617862763873649236587264782365872467823,-149023932491,-34873298478923748973289476592365782689523657926958326459823659726598237503297598246583657924628934928357891,-26589237985678256786763278562876389472836578264892365427961
31 changes: 31 additions & 0 deletions tests/operators/istream_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <cassert>
#include <fstream>
#include <iostream>
#include <sstream>

#include <bigint.hpp>

int main()
{
std::ifstream f("input.txt");
std::string line;

if (f.is_open())
ayaankhan98 marked this conversation as resolved.
Show resolved Hide resolved
{
while (std::getline(f, line, ','))
{
std::stringstream buffer;
libbig::largeInt a;

buffer << line;
buffer >> a;
assert(a == libbig::largeInt(line));
buffer.str(std::string());
}
f.close();
} else {
throw std::runtime_error("Couldn't open input.txt");
}

return 0;
}
2 changes: 1 addition & 1 deletion tests/operators/ostream_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main()

if (f.is_open())
ayaankhan98 marked this conversation as resolved.
Show resolved Hide resolved
{
while (std::getline(f, line))
while (std::getline(f, line, ','))
{
a = libbig::largeInt(line);
buffer << a;
Expand Down