better test coverage for C and C++ language detection
This commit is contained in:
parent
fdaabdd27e
commit
8b179730fb
7 changed files with 32 additions and 2 deletions
0
tests/samples/codefiles/c_and_cpp/empty.h
Normal file
0
tests/samples/codefiles/c_and_cpp/empty.h
Normal file
0
tests/samples/codefiles/c_and_cpp/foo.cpp
Normal file
0
tests/samples/codefiles/c_and_cpp/foo.cpp
Normal file
0
tests/samples/codefiles/c_and_cpp/see.c
Normal file
0
tests/samples/codefiles/c_and_cpp/see.c
Normal file
0
tests/samples/codefiles/c_and_cpp/see.h
Normal file
0
tests/samples/codefiles/c_and_cpp/see.h
Normal file
0
tests/samples/codefiles/c_only/foo.c
Normal file
0
tests/samples/codefiles/c_only/foo.c
Normal file
0
tests/samples/codefiles/c_only/see.h
Normal file
0
tests/samples/codefiles/c_only/see.h
Normal file
|
@ -84,9 +84,7 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
|
|
||||||
now = u(int(time.time()))
|
now = u(int(time.time()))
|
||||||
config = 'tests/samples/sample.cfg'
|
config = 'tests/samples/sample.cfg'
|
||||||
|
|
||||||
entity = 'tests/samples/codefiles/see.h'
|
entity = 'tests/samples/codefiles/see.h'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
retval = execute(args)
|
retval = execute(args)
|
||||||
|
@ -103,3 +101,35 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
|
|
||||||
language = u('C++')
|
language = u('C++')
|
||||||
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['language'], language)
|
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['language'], language)
|
||||||
|
|
||||||
|
def test_c_language_detected_for_header_with_c_files_in_folder(self):
|
||||||
|
response = Response()
|
||||||
|
response.status_code = 500
|
||||||
|
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||||
|
|
||||||
|
now = u(int(time.time()))
|
||||||
|
config = 'tests/samples/sample.cfg'
|
||||||
|
entity = 'tests/samples/codefiles/c_only/see.h'
|
||||||
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
retval = execute(args)
|
||||||
|
self.assertEquals(retval, 102)
|
||||||
|
|
||||||
|
language = u('C')
|
||||||
|
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['language'], language)
|
||||||
|
|
||||||
|
def test_cpp_language_detected_for_header_with_c_and_cpp_files_in_folder(self):
|
||||||
|
response = Response()
|
||||||
|
response.status_code = 500
|
||||||
|
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||||
|
|
||||||
|
now = u(int(time.time()))
|
||||||
|
config = 'tests/samples/sample.cfg'
|
||||||
|
entity = 'tests/samples/codefiles/c_and_cpp/empty.h'
|
||||||
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
retval = execute(args)
|
||||||
|
self.assertEquals(retval, 102)
|
||||||
|
|
||||||
|
language = u('C++')
|
||||||
|
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['language'], language)
|
||||||
|
|
Loading…
Reference in a new issue