first commit
This commit is contained in:
commit
9dd2b0dd46
35
CMakeLists.txt
Normal file
35
CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
||||
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Test Project
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
project(Test
|
||||
LANGUAGES
|
||||
CXX
|
||||
C
|
||||
)
|
||||
|
||||
# specify the C++ standard
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Generates the test runner
|
||||
add_executable(Test
|
||||
${CMAKE_SOURCE_DIR}/src/test.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/features.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/platform_linux.c
|
||||
)
|
||||
target_include_directories(Test PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
# Generates the getplatform bin
|
||||
add_executable(GetPlatform
|
||||
${CMAKE_SOURCE_DIR}/src/main.c
|
||||
${CMAKE_SOURCE_DIR}/src/platform_linux.c
|
||||
)
|
||||
target_include_directories(GetPlatform PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
)
|
||||
29
Jenkinsfile
vendored
Normal file
29
Jenkinsfile
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage('Config') {
|
||||
steps {
|
||||
dir('build') {
|
||||
sh '''
|
||||
cmake --version
|
||||
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
|
||||
'''.stripIndent()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh '''
|
||||
cmake --build build --config Debug --target Test
|
||||
'''.stripIndent()
|
||||
}
|
||||
}
|
||||
stage('Run Test') {
|
||||
steps {
|
||||
sh '''
|
||||
./build/Test
|
||||
'''.stripIndent()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
include/nerd/features.h
Executable file
20
include/nerd/features.h
Executable file
@ -0,0 +1,20 @@
|
||||
/*------------------------------------------------------------------------*
|
||||
Project: Support Recruitment Test
|
||||
|
||||
Copyright (C) 2022 Nintendo, All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain proprietary
|
||||
information of Nintendo and/or its licensed developers and are protected by
|
||||
national and international copyright laws. They may not be disclosed to third
|
||||
parties or copied or duplicated in any form, in whole or in part, without the
|
||||
prior written consent of Nintendo.
|
||||
|
||||
The content herein is highly confidential and should be handled accordingly.
|
||||
*------------------------------------------------------------------------*/
|
||||
#ifndef NERD_FEATURE_H
|
||||
#define NERD_FEATURE_H
|
||||
|
||||
extern "C" int nerd_add(int a, int b);
|
||||
extern "C" int nerd_mul(int a, int b);
|
||||
|
||||
#endif // NERD_FEATURE_H
|
||||
19
include/nerd/platform.h
Executable file
19
include/nerd/platform.h
Executable file
@ -0,0 +1,19 @@
|
||||
/*------------------------------------------------------------------------*
|
||||
Project: Support Recruitment Test
|
||||
|
||||
Copyright (C) 2022 Nintendo, All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain proprietary
|
||||
information of Nintendo and/or its licensed developers and are protected by
|
||||
national and international copyright laws. They may not be disclosed to third
|
||||
parties or copied or duplicated in any form, in whole or in part, without the
|
||||
prior written consent of Nintendo.
|
||||
|
||||
The content herein is highly confidential and should be handled accordingly.
|
||||
*------------------------------------------------------------------------*/
|
||||
#ifndef NERD_FEATURE_H
|
||||
#define NERD_FEATURE_H
|
||||
|
||||
const char *get_platform_name();
|
||||
|
||||
#endif // NERD_FEATURE_H
|
||||
24
src/features.cpp
Executable file
24
src/features.cpp
Executable file
@ -0,0 +1,24 @@
|
||||
/*------------------------------------------------------------------------*
|
||||
Project: Support Recruitment Test
|
||||
|
||||
Copyright (C) 2022 Nintendo, All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain proprietary
|
||||
information of Nintendo and/or its licensed developers and are protected by
|
||||
national and international copyright laws. They may not be disclosed to third
|
||||
parties or copied or duplicated in any form, in whole or in part, without the
|
||||
prior written consent of Nintendo.
|
||||
|
||||
The content herein is highly confidential and should be handled accordingly.
|
||||
*------------------------------------------------------------------------*/
|
||||
#include "nerd/features.h"
|
||||
|
||||
extern "C" int nerd_add(int a, int b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
extern "C" int nerd_mul(int a, int b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
22
src/main.c
Executable file
22
src/main.c
Executable file
@ -0,0 +1,22 @@
|
||||
/*------------------------------------------------------------------------*
|
||||
Project: Support Recruitment Test
|
||||
|
||||
Copyright (C) 2022 Nintendo, All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain proprietary
|
||||
information of Nintendo and/or its licensed developers and are protected by
|
||||
national and international copyright laws. They may not be disclosed to third
|
||||
parties or copied or duplicated in any form, in whole or in part, without the
|
||||
prior written consent of Nintendo.
|
||||
|
||||
The content herein is highly confidential and should be handled accordingly.
|
||||
*------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nerd/platform.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("Hello Support from %s\n", get_platform_name());
|
||||
return 0;
|
||||
}
|
||||
23
src/platform_linux.c
Executable file
23
src/platform_linux.c
Executable file
@ -0,0 +1,23 @@
|
||||
/*------------------------------------------------------------------------*
|
||||
Project: Support Recruitment Test
|
||||
|
||||
Copyright (C) 2022 Nintendo, All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain proprietary
|
||||
information of Nintendo and/or its licensed developers and are protected by
|
||||
national and international copyright laws. They may not be disclosed to third
|
||||
parties or copied or duplicated in any form, in whole or in part, without the
|
||||
prior written consent of Nintendo.
|
||||
|
||||
The content herein is highly confidential and should be handled accordingly.
|
||||
*------------------------------------------------------------------------*/
|
||||
#include "nerd/platform.h"
|
||||
|
||||
#ifndef __linux__
|
||||
#error the linux platform file is compiled with an incompatible compiler
|
||||
#endif
|
||||
|
||||
const char *get_platform_name()
|
||||
{
|
||||
return "Linux";
|
||||
}
|
||||
110
src/test.cpp
Executable file
110
src/test.cpp
Executable file
@ -0,0 +1,110 @@
|
||||
/*------------------------------------------------------------------------*
|
||||
Project: Support Recruitment Test
|
||||
|
||||
Copyright (C) 2022 Nintendo, All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain proprietary
|
||||
information of Nintendo and/or its licensed developers and are protected by
|
||||
national and international copyright laws. They may not be disclosed to third
|
||||
parties or copied or duplicated in any form, in whole or in part, without the
|
||||
prior written consent of Nintendo.
|
||||
|
||||
The content herein is highly confidential and should be handled accordingly.
|
||||
*------------------------------------------------------------------------*/
|
||||
#include "nerd/features.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#if __cplusplus != 201103L
|
||||
#error The source is not compiled in c++11 mode
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define ASSERT_EQUAL(a, b) \
|
||||
do \
|
||||
{ \
|
||||
if ((a) != (b)) \
|
||||
{ \
|
||||
std::cerr << "FAILURE: expected " #a "=" << (a) << " got " #b "=" << (b) << "\n"; \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
namespace
|
||||
{
|
||||
bool test_add()
|
||||
{
|
||||
for (int i = 0; i < 512; ++i)
|
||||
{
|
||||
for (int j = 0; j < 512; ++j)
|
||||
{
|
||||
int expected = i + j;
|
||||
int result = nerd_add(i, j);
|
||||
ASSERT_EQUAL(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mul()
|
||||
{
|
||||
for (int i = 0; i < 512; ++i)
|
||||
{
|
||||
for (int j = 0; j < 512; ++j)
|
||||
{
|
||||
int expected = i * j;
|
||||
int result = nerd_mul(i, j);
|
||||
ASSERT_EQUAL(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_fail()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // namespace anonymous
|
||||
|
||||
extern "C" int main(int argc, char **argv)
|
||||
{
|
||||
std::cout << "Test program\n";
|
||||
|
||||
struct
|
||||
{
|
||||
const char *name;
|
||||
bool (*func)();
|
||||
} test_list[] = {
|
||||
{"Addition", test_add},
|
||||
{"Multiplication", test_mul},
|
||||
{"WontWork", test_fail}};
|
||||
static constexpr auto test_list_len = sizeof(test_list) / sizeof(test_list[0]);
|
||||
|
||||
bool success = true;
|
||||
size_t failures = 0;
|
||||
size_t successes = 0;
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < test_list_len; ++i)
|
||||
{
|
||||
bool result = test_list[i].func();
|
||||
if (result)
|
||||
{
|
||||
std::cout << "[ SUCCESS ] TestSuite." << test_list[i].name << "\n";
|
||||
successes++;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "[ FAILURE ] TestSuite." << test_list[i].name << "\n";
|
||||
failures++;
|
||||
}
|
||||
success = success && result;
|
||||
}
|
||||
|
||||
std::cout << "[ RESULTS ] " << successes << "/" << i << "\n";
|
||||
|
||||
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user