d
This commit is contained in:
1 parent
650bf410e8
commit
e3b5ddea44
8 files changed
+69
-30
No files matched your search
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#include "Memory.h"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
std::cout
|
|
||||||
<< test_memory_generateConstPlayfield()
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
File renamed without changes.
File renamed without changes.
@@ -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
|
|
||||||
Executable
+2
@@ -0,0 +1,2 @@
|
|||||||
|
echo "node main.js" > test_memory_JavaScript
|
||||||
|
chmod +x test_memory_JavaScript
|
||||||
@@ -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());
|
||||||
|
}
|
||||||
@@ -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())
|
||||||
Reference in new issue
Block a user