add very basic NR test
Some checks failed
Linux arm64 / Build (push) Failing after 8m57s

This commit is contained in:
2024-02-25 20:29:10 +01:00
parent abd5c7ac56
commit b8ee47e267

53
test/test_rational.cpp Normal file
View File

@@ -0,0 +1,53 @@
#include "NR.h"
#include <cassert>
static void test() {
/*NR* frac = new NR;
NR frac2(3);
NR frac3(2, 5);
int a, b;
std::cout << "PGCD : entrez deux entiers" << std::endl;
std::cin >> a >> b;
std::cout << PGCD(a, b) << std::endl;
std::cout << "frac : entrez deux entiers" << std::endl;
std::cin >> a >> b;
NR fractest(a, b);
std::cout << fractest << " + " << frac3 << " = " << std::endl;
std::cout << ">> " << (fractest + frac3) << std::endl;
std::cout << ">> " << (fractest + frac3).GetNumerator() << "/" << (fractest + frac3).GetDenominator() << std::endl;
fractest = fractest + frac3;
std::cout << ">> " << fractest << std::endl;
// frac->NRset(2, 4);
NR anotherfrac;
std::cin >> anotherfrac;
std::cout << "Compare " << fractest << " and " << anotherfrac << " : ==? " << (fractest == anotherfrac) << " <? "
<< (fractest < anotherfrac) << " >=? " << (fractest >= anotherfrac) << std::endl;
std::cout << anotherfrac << " - " << *frac << " = " << anotherfrac - *frac << std::endl;
std::cout << anotherfrac << " * " << *frac << " = " << std::endl << ">> " << anotherfrac * *frac << std::endl;
fractest = anotherfrac * *frac;
std::cout << ">> " << fractest << std::endl;
fractest.Reduce();
std::cout << ">> " << fractest << std::endl;
std::cout << anotherfrac << " / " << frac2 << " = " << anotherfrac / frac2 << std::endl;
NR numNR(2, 4);
NR otherNR(3, 1);
std::cout << numNR << " - " << otherNR << " = " << std::endl;
NR subNR = numNR - otherNR;
std::cout << ">> " << (numNR - otherNR) << std::endl << ">> " << subNR << std::endl;
delete frac;*/
NR frac1 {2};
NR frac2 {1};
assert(frac1 != frac2);
frac2 *= 2;
assert(frac1 == frac2);
}
int main(int argc, char** argv) {
test();
return 0;
}