diff --git a/README.md b/README.md index 8fac466..bc335f7 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ arch -x86_64 brew install libzip *see how to install the bost library below* *Using Brew and Rosetta Intel emulator* + Before installing Homebrew you will need to install Rosetta2 emulator for the new ARM silicon (M1 chip). Install Rosetta2 via terminal using: `/usr/sbin/softwareupdate --install-rosetta --agree-to-license` @@ -41,8 +42,6 @@ Once Homebrew for M1 ARM is installed use this Homebrew command to install packa Boost library: `arch -x86_64 brew install boost` -*MacOS* -```arch -x86_64 brew install libzip``` # Building ``` @@ -73,3 +72,31 @@ dotfiles/hidden directories. It will also explore any subdirectories that is ins of the puzzle directory that you have created. If any of the files are not prefixed with `.`, then that file will be added to the final zipped version of it. +## Future Puzzle Ideas + +* TODO Map Puzzle +- https://www.lipscomb.edu/sites/default/files/2021-11/UMAR-21-030%20-%20Campus%20Map%20-%20FINAL.pdf + +* Color Puzzle +- Change the answer so it does not have to be concatenated +- Randomly select 1 index from each of the colors +- Answer is the sum of the two + +* QR Puzzle +- Single QR code +- Randomly mess it up and have the user fix it + +* Maze Puzzle +- PPM Generation +- Only 1 shortest path +- Multiple paths +- Final solution +- Generate 8x8 (or maybe 10x10) maze + - Constraints: + 1. Must have multiple paths, but only 1 shortest path. + 2. The start and end must be at opposite corners. + 3. The solution must contains compression (all duplicate letters must be in compressed) + +* Meta Final Puzzle +- Hidden messages/symbols in previous instructions. +- Must find these to complete final puzzle diff --git a/src/build.sh b/src/build.sh index 7b4c83d..2135cf9 100755 --- a/src/build.sh +++ b/src/build.sh @@ -8,7 +8,7 @@ CXXDEPS="./*.cpp" if [ "$1" == "c" ]; then - echo "Cleaning up..." + echo "Cleaning..." rm -rf main *.zip ./zipfiles/* rm ./files*/instructions.html elif [ "$1" == "a" ]; @@ -22,5 +22,6 @@ then ./main else echo "Building..." + mkdir -p ./zipfiles g++ $CXXFLAGS $CXXDEPS $CXXLINKS fi diff --git a/src/tests/entry-point-tests.cpp b/src/tests/entry-point-tests.cpp deleted file mode 100644 index 2d6d22a..0000000 --- a/src/tests/entry-point-tests.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE EntryPointTests -#include -#include "../main.cpp" - -BOOST_AUTO_TEST_CASE(test_can_initialize_be_called) -{ - const char * inp[1]; - const char * str = "./Program"; - inp[0] = str; - int argc = 1; - initialize(argc, inp); -} - diff --git a/src/tests/example-puzzle-tests.cpp b/src/tests/example-puzzle-tests.cpp deleted file mode 100644 index 2fb3d25..0000000 --- a/src/tests/example-puzzle-tests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE ExamplePuzzleTests -#include -#include -#include -#include -#include -#include "../puzzles/hello-world/hello-world.cpp" - -BOOST_AUTO_TEST_CASE(test_do_all_attributes_of_example_puzzle_make_sense) -{ - HelloWorld test_puzzle = HelloWorld(); - - chdir("puzzles"); - std::string puzzle_file = test_puzzle.init("Example", "congrats.zip"); - BOOST_ASSERT(test_puzzle.get_answer() == "4"); - std::unique_ptr err_ptr = nullptr; - zip_t * test_puzzle_zip = zip_open(puzzle_file.c_str(), 0, err_ptr.get()); - BOOST_ASSERT(!err_ptr.get()); // Assert no errors in opening zip - BOOST_ASSERT(zip_fopen(test_puzzle_zip, (test_puzzle.get_name() + ".html").c_str(), 0)); - zip_close(test_puzzle_zip); - BOOST_ASSERT(remove(puzzle_file.c_str()) == 0); -} - diff --git a/src/tests/html-generator-tests.cpp b/src/tests/html-generator-tests.cpp deleted file mode 100644 index b6128a3..0000000 --- a/src/tests/html-generator-tests.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE HtmlGeneratorTests -#include -#include -#include -#include "../include/html-generator.h" - -BOOST_AUTO_TEST_CASE(test_can_generate_be_called) -{ - chdir("puzzles"); - try { - BOOST_ASSERT(generate_html("title", "test", 0) == "title.html"); - BOOST_ASSERT(remove("title.html") == 0); - } - catch(std::exception e) { - std::cerr << e.what(); - } -} - -BOOST_AUTO_TEST_CASE(test_does_generate_populate_html_file) -{ - try { - std::string file_path = generate_html("test", "abc", 0); - std::ifstream file = std::ifstream(file_path); - std::stringstream buffer; - buffer << file.rdbuf(); - BOOST_ASSERT(buffer.str().length() >= 7); - BOOST_ASSERT(remove(file_path.c_str()) == 0); - } - catch (std::exception e) { - std::cerr << e.what(); - } -} - -BOOST_AUTO_TEST_CASE(test_does_generate_put_title_in_html_file) -{ - try { - std::string file_path = generate_html("test", "abc", 0); - std::ifstream file = std::ifstream(file_path); - std::stringstream buffer; - buffer << file.rdbuf(); - BOOST_ASSERT(buffer.str().find("test") != std::string::npos); - BOOST_ASSERT(remove(file_path.c_str()) == 0); - } - catch (std::exception e) { - std::cerr << e.what(); - } - -} - -BOOST_AUTO_TEST_CASE(test_does_generate_put_description_in_html_file) -{ - try { - std::string file_path = generate_html("test", "abc", 0); - std::ifstream file = std::ifstream(file_path); - std::stringstream buffer; - buffer << file.rdbuf(); - BOOST_ASSERT(buffer.str().find("abc") != std::string::npos); - BOOST_ASSERT(remove(file_path.c_str()) == 0); - } - catch (std::exception e) { - std::cerr << e.what(); - } -} - -BOOST_AUTO_TEST_CASE(test_does_generate_put_seed_in_html_file) -{ - try { - std::string file_path = generate_html("test", "abc", 6578293); - std::ifstream file = std::ifstream(file_path); - std::stringstream buffer; - buffer << file.rdbuf(); - BOOST_ASSERT(buffer.str().find("6578293") != std::string::npos); - BOOST_ASSERT(remove(file_path.c_str()) == 0); - } - catch (std::exception e) { - std::cerr << e.what(); - } -} - diff --git a/src/tests/puzzle-tests.cpp b/src/tests/puzzle-tests.cpp deleted file mode 100644 index d259a43..0000000 --- a/src/tests/puzzle-tests.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE PuzzleTests -#include -#include -#include "../util/Puzzle.h" -#include -#include -#include -#include "../util/zip/Zipper.h" - -class PuzzleFixture : public Puzzle -{ -protected: - void set_answer() - { - answer = "abc123"; - } - std::vector generate_files(std::string contained_zip_path) - { - std::ofstream out("hello.txt"); - out << "Hi! The seed to this puzzle is " << get_seed(); - out.close(); - return {contained_zip_path, "hello.txt"}; - } -}; - -BOOST_AUTO_TEST_CASE(setup) -{ - std::ofstream out("congrats.txt"); - out << "Woo! You completed the puzzle!"; - out.close(); - try - { - zip_files("congrats.zip", {"congrats.txt"}); - } - catch(const std::exception& e) - { - std::cerr << e.what() << '\n'; - } - - -} - -BOOST_AUTO_TEST_CASE(test_can_puzzle_be_initialized) -{ - PuzzleFixture a = PuzzleFixture(); - BOOST_ASSERT(a.init("test", "congrats.zip", 0) == "test.zip"); -} - -BOOST_AUTO_TEST_CASE(test_can_puzzle_be_initialized_with_previous_zip_file) -{ - PuzzleFixture a = PuzzleFixture(); - BOOST_ASSERT(a.init("test2", "test.zip", 0) == "test2.zip"); -} - -BOOST_AUTO_TEST_CASE(test_can_puzzle_be_initialized_with_no_seed) -{ - PuzzleFixture a = PuzzleFixture(); - BOOST_ASSERT(a.init("test3", "test2.zip") == "test3.zip"); -} - -BOOST_AUTO_TEST_CASE(test_can_seed_be_rolled) -{ - PuzzleFixture a = PuzzleFixture(); - BOOST_ASSERT(rand() != rand()); -} - -BOOST_AUTO_TEST_CASE(cleanup) -{ - remove("hello.txt"); - remove("congrats.txt"); - remove("congrats.zip"); - remove("test.zip"); - remove("test2.zip"); - remove("test3.zip"); - remove("test4.zip"); -} diff --git a/src/tests/rng-tests.cpp b/src/tests/rng-tests.cpp deleted file mode 100644 index 818ea6f..0000000 --- a/src/tests/rng-tests.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE RandomNumberGenTests -#include -#include "../util/rng/RandomNumber.h" - -BOOST_AUTO_TEST_CASE(test_generator_works_with_large_numbers) -{ - int number = get_num(-1000000, 1000000); - BOOST_ASSERT(number >= -1000000); - BOOST_ASSERT(number <= 1000000); -} - -BOOST_AUTO_TEST_CASE(test_generator_works_with_small_numbers) -{ - int number = get_num(0, 5); - BOOST_ASSERT(number >= 0); - BOOST_ASSERT(number <= 5); -} - -BOOST_AUTO_TEST_CASE(test_generator_works_with_large_numbers_inversed) -{ - int number = get_num(1000000, -1000000); - BOOST_ASSERT(number >= -1000000); - BOOST_ASSERT(number <= 1000000); -} - -BOOST_AUTO_TEST_CASE(test_generator_works_with_small_numbers_inversed) -{ - int number = get_num(5, 0); - BOOST_ASSERT(number >= 0); - BOOST_ASSERT(number <= 5); -} diff --git a/src/tests/utility-tests.cpp b/src/tests/utility-tests.cpp deleted file mode 100644 index ee21e34..0000000 --- a/src/tests/utility-tests.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE UtilityTests -#include -#include -#include -#include -#include -#include -#include "../util/zip/Zipper.h" - -struct FileStructureFixture -{ - std::vector file_names; - FileStructureFixture() - { - file_names = {"abc.txt"}; - std::ofstream writer = std::ofstream(file_names[0], std::ios::out); - writer << "abc"; - writer.flush(); - writer.close(); - } - ~FileStructureFixture() { - remove("abc.txt"); - } -}; - -BOOST_FIXTURE_TEST_CASE(test_zipper_does_create_zip_file, FileStructureFixture) -{ - try - { - zip_files("test.zip", file_names); - BOOST_ASSERT(remove("test.zip") == 0); - } - catch(const std::exception& e) - { - std::cerr << e.what() << '\n'; - BOOST_ASSERT(false); - } -} - -BOOST_FIXTURE_TEST_CASE(test_zipper_does_create_zip_file_with_password, FileStructureFixture) -{ - try - { - zip_files("test.zip", file_names, "abcdef"); - } - catch(const std::exception & err) - { - std::cerr << err.what() << "\n"; - } - BOOST_ASSERT(remove("test.zip") == 0); -} - -BOOST_FIXTURE_TEST_CASE(test_zipper_does_write_file_to_zip_file, FileStructureFixture) -{ - try - { - zip_files("test.zip", file_names); - } - catch(const std::exception & err) - { - std::cerr << err.what() << "\n"; - } - int * err = nullptr; - zip_t * archive = zip_open("test.zip", 0, err); - - BOOST_ASSERT(zip_fopen(archive, file_names[0].c_str(), 0) != nullptr); - BOOST_ASSERT(remove("test.zip") == 0); -} - -BOOST_FIXTURE_TEST_CASE(test_zipper_does_write_encrypted_file_to_zip_file, FileStructureFixture) -{ - try - { - zip_files("test.zip", file_names, "abc"); - } - catch(const std::exception & err) - { - std::cerr << err.what() << "\n"; - } - - int * err = nullptr; - zip_t * archive = zip_open("test.zip", 0, err); - - BOOST_ASSERT(zip_fopen_encrypted(archive, file_names[0].c_str(), 0, "abc") != nullptr); - BOOST_ASSERT(zip_fopen(archive, file_names[0].c_str(), 0) == nullptr); - BOOST_ASSERT(remove("test.zip") == 0); -} - -BOOST_AUTO_TEST_CASE(test_zipper_can_write_multiple_files) -{ - std::vector file_names; - for(int i = 0; i < 26; ++i) - { - file_names.push_back("test_file_"); - file_names[i] += ('a' + i); - std::ofstream writer = std::ofstream(file_names[i], std::ios::out); - writer << "test"; - writer.flush(); - writer.close(); - } - - try - { - zip_files("test.zip", file_names); - } - catch(const std::exception & err) - { - std::cerr << err.what() << "\n"; - } - int err = 0; - zip_t * archive = zip_open("test.zip", 0, &err); - BOOST_ASSERT(archive); - - for(std::string file_name : file_names) - { - zip_file_t * file = zip_fopen(archive, file_name.c_str(), 0); - BOOST_ASSERT(zip_fclose(file) == 0); - } - - for(std::string file_name : file_names) - remove(file_name.c_str()); - - remove("test.zip"); -}