Last active
July 17, 2016 07:11
-
-
Save al3rez/7a16b6f31b78c5aea8c99afb010097f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
int | |
tomat(int length, FILE *stdout_) | |
{ | |
int remain = 0; | |
while ((remain = (length -= 1)) != 0) | |
{ | |
fprintf(stdout_, "00:%d\n", remain); | |
sleep(1); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import ctypes | |
import unittest | |
class TomatTestCase(unittest.TestCase): | |
def setUp(self): | |
self.lib = ctypes.CDLL('./tomat.so') | |
def test_prints_every_second(self): | |
seconds = ['00:1', '00:2', '00:2', '00:3', '00:4', '00:5', | |
'00:6', '00:7', '00:8', '00:9'] | |
self.lib.tomat(10, sys.stdout.fileno()) | |
self.assertEqual(output, seconds[::-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment