Михаил Капелько 1 month ago
parent
commit
e3b5ddea44
8 changed files with 69 additions and 30 deletions
  1. +0
    -16
      C++/Memory.Aux.cpp
  2. +0
    -8
      C++/main.cpp
  3. +0
    -0
      Memory.Test.cpp
  4. +0
    -0
      Memory.h
  5. +1
    -6
      gen-C++
  6. +2
    -0
      gen-JavaScript
  7. +35
    -0
      main.cpp
  8. +31
    -0
      main.js

+ 0
- 16
C++/Memory.Aux.cpp 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;
}

+ 0
- 8
C++/main.cpp View File

@@ -1,8 +0,0 @@
#include "Memory.h"
#include <iostream>

int main() {
std::cout
<< test_memory_generateConstPlayfield()
<< std::endl;
}

C++/Memory.Test.cpp → Memory.Test.cpp View File


C++/Memory.h → Memory.h View File


+ 1
- 6
gen-C++ View File

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

+ 2
- 0
gen-JavaScript View File

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

+ 35
- 0
main.cpp 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
- 0
main.js 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())

Loading…
Cancel
Save