-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <lauxlib.h> | ||
#include <lua.h> | ||
#include <lualib.h> | ||
#include <string.h> | ||
|
||
#include "lualibutils.h" | ||
|
||
char *getOsName() | ||
{ | ||
#ifdef _WIN32 | ||
return "Windows"; | ||
#elif _WIN64 | ||
return "Windows"; | ||
#elif __APPLE__ || __MACH__ | ||
return "MacOS"; | ||
#elif __linux__ | ||
return "Linux"; | ||
#elif __FreeBSD__ | ||
return "FreeBSD"; | ||
#elif __unix || __unix__ | ||
return "Unix"; | ||
#else | ||
return "Other"; | ||
#endif | ||
} | ||
|
||
static int luaGetOsName(lua_State *L) | ||
{ | ||
lua_pushstring(L, getOsName()); | ||
|
||
return 1; | ||
} | ||
|
||
static const struct luaL_Reg luaOS[] = { | ||
{"getName", luaGetOsName}, | ||
{NULL, NULL}, | ||
}; | ||
|
||
int luaopen_cluautils_os(lua_State *L) | ||
{ | ||
lua_createtable(L, 0, 1); | ||
registerFields(L, luaOS); | ||
|
||
return 1; | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
local t = require("src.tests") | ||
local os = require("cluautils.os") | ||
local strutils = require("src.string_utils.string_utils") | ||
|
||
t.describe("OS module tests", function () | ||
t.it("os module has name function", function () | ||
local name = os.getName() | ||
|
||
t.expect(type(name) == "string", "os type should be string") | ||
t.expect(not strutils.isEmpty(name), "os type shouldn't be empty") | ||
end) | ||
end) |