Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane committed Oct 18, 2023
1 parent 6400871 commit c4338a0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/commands/run/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ def test_mem_limit_kill(create_package, time_tool):
end_time = time.time()

assert e.value.code == 1
assert end_time - start_time < 5 # The solution runs for 20 seconds, but it immediately exceeds memory limit,
# so it should be killed.
assert end_time - start_time < 10 # The solution runs for 20 seconds, but it immediately exceeds memory limit,
# so it should be killed.


@pytest.mark.parametrize("create_package", [get_undocumented_options_package_path()], indirect=True)
Expand Down
16 changes: 13 additions & 3 deletions tests/packages/lim/prog/lim2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
#include <chrono>

using namespace std;
using namespace std::chrono_literals;
using namespace std::chrono;

int wait(int secs) {
auto start = high_resolution_clock::now();
int i = 0;
while (duration_cast<seconds>(high_resolution_clock::now() - start).count() < secs)
i++;
return i;
}

int main() {
int a, b;
cin >> a >> b;

if (a == 2 && b == 1) {
this_thread::sleep_for(6s);
int i = wait(6);
a += i - i;
}
else {
this_thread::sleep_for(2s);
int i = wait(2);
a += i - i;
}

cout << a + b << endl;
Expand Down
13 changes: 11 additions & 2 deletions tests/packages/vso/prog/vso4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@
#include <bits/stdc++.h>

using namespace std;
using namespace std::chrono;

int rnd() {
return rand() % 100;
}

int wait(int secs) {
auto start = high_resolution_clock::now();
int i = 0;
while (duration_cast<seconds>(high_resolution_clock::now() - start).count() < secs)
i++;
return i;
}

int main() {
int a, b;
cin >> a >> b;
if (a == 1 && b == 1) {
this_thread::sleep_for(chrono::seconds(3));
cout << a + b;
int i = wait(3);
cout << a + b + i - i;
}
else if (a == 1 && b == 2) {
vector<int*> v;
Expand Down
13 changes: 11 additions & 2 deletions tests/packages/vso/prog/vso7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
#include <bits/stdc++.h>

using namespace std;
using namespace std::chrono;

int rnd() {
return rand() % 100;
}

int wait(int secs) {
auto start = high_resolution_clock::now();
int i = 0;
while (duration_cast<seconds>(high_resolution_clock::now() - start).count() < secs)
i++;
return i;
}

int main() {
int a, b;
cin >> a >> b;
Expand All @@ -23,8 +32,8 @@ int main() {
cout << a + b;
}
else if (a == 1 && b == 3) {
this_thread::sleep_for(chrono::seconds(3));
cout << a + b;
int i = wait(3);
cout << a + b + i - i;
}
else if (a == 1 && b == 4) {
int c = 0;
Expand Down

0 comments on commit c4338a0

Please sign in to comment.