This commit is contained in:
Михаил Капелько
2024-05-23 23:02:46 +03:00
parent 7f2dbfd65c
commit ad7efc5f19
13 changed files with 80 additions and 56 deletions

View File

@@ -1,11 +1,8 @@
#include <map>
#include <string>
#include <vector>
#include "cli.h"
#include "cli_Context.h"
#include "memory.h"
#include "memory_Context.h"
#include "shell.h"
#include "main.h"
// Exit
//

View File

@@ -1,9 +0,0 @@
#include "cli_Context.h"
#ifndef cli_HEADER
#define cli_HEADER
cli_Context cli_greetUser(cli_Context);
cli_Context cli_showHelp(cli_Context);
#endif // cli_HEADER

View File

@@ -1,11 +1,8 @@
#include <map>
#include <string>
#include <vector>
#include "cli.h"
#include "cli_Context.h"
#include "memory.h"
#include "memory_Context.h"
#include "shell.h"
#include "main.h"
std::string cli_test_exit_e(
) {

View File

@@ -1,10 +0,0 @@
#include <string>
#ifndef cli_test_HEADER
#define cli_test_HEADER
std::string cli_test_greetUser();
std::string cli_test_showHelp_h();
std::string cli_test_showHelp_help();
#endif // cli_test_HEADER

24
v4/cxx-headers Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
DIR=$(cd "$(dirname "$0")" ; pwd -P)
TMP=/tmp/cxx-headers.tmp
grep '^memory_Context ' memory.cpp > $TMP
grep '^std::string ' memory_test.cpp >> $TMP
#grep '^memory_Context ' cli.cpp >> $TMP
IN=$TMP
OUT=$DIR/main.h
echo '
#include "memory_Context.h"
#ifndef main_HEADER
#define main_HEADER
' > $OUT
sed -Ef cxx-headers.sed <$IN >>$OUT
echo '
#endif // main_HEADER
' >> $OUT

15
v4/cxx-headers.sed Normal file
View File

@@ -0,0 +1,15 @@
# #} -> }
#s|#}|}|
# # -> //
#s|#|//|
# dict[X, Y] -> std::map<X, Y>
#s_dict\[(.*), (.*)\]_std::map<\1, \2>_
# def functionName(X) -> Y -> Y functionName(X) {
#s|def (.*) -> (.*):|\2 \1 {|
s|memory_Context (.*)\(|memory_Context \1(memory_Context);|
s|std::string (.*)\(|std::string \1();|

View File

@@ -1,10 +1,8 @@
c++ -o test_memory_C++ -std=c++11 -I. \
cli.cpp \
cli_Context.cpp \
cli_test.cpp \
memory.cpp \
memory_Context.cpp \
memory_test.cpp \
shell.cpp \
shell_Context.cpp \
main.cpp
# cli.cpp \
# cli_test.cpp \

View File

@@ -1,32 +1,30 @@
#include <iostream>
#include <string>
#include <vector>
#include "cli_test.h"
#include "cli_Context.h"
#include "memory_test.h"
#include "main.h"
#include "memory_Context.h"
#include "shell.h"
int main() {
std::cout
<< memory_test_detectMismatchedItems()
<< std::endl
<< memory_test_detectMismatchedItems_itemTwice()
<< std::endl
<< memory_test_detectVictory()
<< std::endl
<< memory_test_generateConstPlayfield()
<< std::endl
<< memory_test_hideMatchingItems()
<< std::endl
<< memory_test_selectItem_1x()
<< std::endl
<< memory_test_selectItem_2x()
<< std::endl
<< memory_test_selectItem_3x()
<< std::endl
<< memory_test_shouldDeselectMismatchedItems()
<< std::endl
<< memory_test_shouldDeselectMismatchedItems_itemTwice()
<< std::endl
<< memory_test_shouldDetectVictory()
<< std::endl
<< memory_test_shouldHideMatchingItems()
<< std::endl
;
/*
std::cout
<< cli_test_greetUser()
<< std::endl
@@ -51,4 +49,5 @@ int main() {
}
std::cout << c.output << std::endl;
}
*/
}

22
v4/main.h Normal file
View File

@@ -0,0 +1,22 @@
#include "memory_Context.h"
#ifndef main_HEADER
#define main_HEADER
memory_Context memory_detectMismatchedItems(memory_Context);
memory_Context memory_detectVictory(memory_Context);
memory_Context memory_generateConstPlayfield(memory_Context);
memory_Context memory_hideMatchingItems(memory_Context);
memory_Context memory_selectItem(memory_Context);
std::string memory_test_detectMismatchedItems();
std::string memory_test_detectMismatchedItems_itemTwice();
std::string memory_test_detectVictory();
std::string memory_test_generateConstPlayfield();
std::string memory_test_hideMatchingItems();
std::string memory_test_selectItem_1x();
std::string memory_test_selectItem_2x();
std::string memory_test_selectItem_3x();
#endif // main_HEADER

View File

@@ -1,11 +1,8 @@
#include <map>
#include <string>
#include <vector>
#include "cli.h"
#include "cli_Context.h"
#include "memory.h"
#include "memory_Context.h"
#include "shell.h"
#include "main.h"
// Detect mismatched items
//

View File

@@ -1,11 +1,8 @@
#include <map>
#include <string>
#include <vector>
#include "cli.h"
#include "cli_Context.h"
#include "memory.h"
#include "memory_Context.h"
#include "shell.h"
#include "main.h"

View File

@@ -4,11 +4,8 @@ def includes():
return """#include <map>
#include <string>
#include <vector>
#include "cli.h"
#include "cli_Context.h"
#include "memory.h"
#include "memory_Context.h"
#include "shell.h"
#include "main.h"
"""
def replaceAnd(s):