Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Venix Cador
- // bigint Test Program
- //
- // Tests: int constructor, uses ==
- //
- #include "bigint.h"
- #include <cassert>
- //===========================================================================
- int main()
- {
- std::cout << "Testing factorial function!" << std::endl;
- {
- bigint bi = 1,
- result = 0;
- result = bi.factorial();
- assert(result == 1);
- std::cout << "Test: " << bi << "! == " << result << std::endl;
- }
- {
- bigint bi = 2,
- result = 0;
- result = bi.factorial();
- assert(result == 2);
- std::cout << "Test: " << bi << "! == " << result << std::endl;
- }
- {
- bigint bi = 3,
- result = 0;
- result = bi.factorial();
- assert(result == 6);
- std::cout << "Test: " << bi << "! == " << result << std::endl;
- }
- {
- bigint bi = 4,
- result = 0;
- result = bi.factorial();
- assert(result == 24);
- std::cout << "Test: " << bi << "! == " << result << std::endl;
- }
- {
- bigint bi = 5,
- result = 0;
- result = bi.factorial();
- assert(result == 120);
- std::cout << "Test: " << bi << "! == " << result << std::endl;
- }
- {
- bigint bi = 20,
- result = 0;
- result = bi.factorial();
- assert(result == bigint("2432902008176640000"));
- std::cout << "Test: " << bi << "! == " << result << std::endl;
- }
- {
- bigint bi = 50,
- result = 0;
- result = bi.factorial();
- assert(result == bigint("30414093201713378043612608166064768844377641568960512000000000000"));
- std::cout << "Test: " << bi << "! == " << result << std::endl;
- }
- {
- bigint bi = 100,
- result = 0;
- result = bi.factorial();
- assert(result == bigint("93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000"));
- std::cout << "Test: " << bi << "! == " << result << std::endl;
- }
- std::cout << "Done with testing factorial." << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment