Skip to content

Instantly share code, notes, and snippets.

@al3rez
Last active July 17, 2016 07:11
Show Gist options
  • Save al3rez/7a16b6f31b78c5aea8c99afb010097f2 to your computer and use it in GitHub Desktop.
Save al3rez/7a16b6f31b78c5aea8c99afb010097f2 to your computer and use it in GitHub Desktop.
#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;
}
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