This commit is contained in:
Михаил Капелько
2024-03-26 23:03:54 +03:00
parent 650bf410e8
commit e3b5ddea44
8 changed files with 69 additions and 30 deletions

View File

@@ -1,16 +0,0 @@
#include <map>
#include "Memory.h"
std::map<int, int> memory_generateConstPlayfield(
int n
) {
std::map<int, int> idGroups;
auto id = 0;
for (int gid = 0; gid < n; ++gid) {
idGroups[id] = gid;
id += 1;
idGroups[id] = gid;
id += 1;
}
return idGroups;
}

View File

@@ -1,8 +0,0 @@
#include "Memory.h"
#include <iostream>
int main() {
std::cout
<< test_memory_generateConstPlayfield()
<< std::endl;
}

View File

@@ -1,6 +1 @@
c++ -o test_memory_C++ \ c++ -o test_memory_C++ -std=c++11 main.cpp
-std=c++11 \
-IC++ \
C++/Memory.Aux.cpp \
C++/Memory.Test.cpp \
C++/main.cpp

2
gen-JavaScript Executable file
View File

@@ -0,0 +1,2 @@
echo "node main.js" > test_memory_JavaScript
chmod +x test_memory_JavaScript

35
main.cpp Normal file
View File

@@ -0,0 +1,35 @@
#include <map>
#include <string>
std::map<int, int> memory_generateConstPlayfield(
int n
) {
std::map<int, int> idGroups;
auto id = 0;
for (auto gid = 0; gid < n; ++gid) {
idGroups[id] = gid;
id += 1;
idGroups[id] = gid;
id += 1;
}
return idGroups;
}
std::string test_memory_generateConstPlayfield() {
auto idGroups = memory_generateConstPlayfield(2);
if (
idGroups.size() == 4 &&
idGroups[0] == 0 &&
idGroups[1] == 0 &&
idGroups[2] == 1 &&
idGroups[3] == 1
) {
return "OK: memory_generateConstPlayfield";
}
return "ERR: memory_generateConstPlayfield";
}
int main() {
printf("%s\n", test_memory_generateConstPlayfield().c_str());
}

31
main.js Normal file
View File

@@ -0,0 +1,31 @@
function memory_generateConstPlayfield(
n
) {
var idGroups = {};
var id = 0;
for (let gid = 0; gid < n; ++gid) {
idGroups[id] = gid;
id += 1;
idGroups[id] = gid;
id += 1;
}
return idGroups;
}
function test_memory_generateConstPlayfield() {
let idGroups = memory_generateConstPlayfield(2)
if (
Object.keys(idGroups).length == 4 &&
idGroups[0] == 0 &&
idGroups[1] == 0 &&
idGroups[2] == 1 &&
idGroups[3] == 1
) {
return "OK: memory_generateConstPlayfield"
}
return "ERR: memory_generateConstPlayfield"
}
console.log(test_memory_generateConstPlayfield())