SS 17

» 2022_SUMMER

개강까지 D-23!

🌱 Google 특강 Day 2

✅ Google Test Framework

C++을 위한 test! 별도의 설치 필요

Install GTest

User’s Guide

블로그 참고

git clone https://github.com/google/googletest.git -b release-1.11.0
cd googletest        # Main directory of the cloned repository.
mkdir build          # Create a directory to hold the build output.
cd build
cmake ..             # Generate native build scripts for GoogleTest.
make
sudo make install
  1. Set up a project
$ mkdir my_project && cd my_project
  1. Create the CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(my_project)

# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)

include(FetchContent)
FetchContent_Declare(
  googletest
  GIT_REPOSITORY https://github.com/google/googletest.git
  GIT_TAG release-1.12.1
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
  1. Create and run a abinary
#include <gtest/gtest.h>

// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
  // Expect two strings not to be equal.
  EXPECT_STRNE("hello", "world");
  // Expect equality.
  EXPECT_EQ(7 * 6, 42);
}

To build the code, add to the end of your CMakeLists.txt file:

enable_testing()

add_executable(
  hello_test
  hello_test.cc
)
target_link_libraries(
  hello_test
  GTest::gtest_main
)

include(GoogleTest)
gtest_discover_tests(hello_test)
  1. Build and run your test:
my_project$ cmake -S . -B build
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
...
-- Build files have been written to: .../my_project/build

my_project$ cmake --build build
Scanning dependencies of target gtest
...
[100%] Built target gmock_main

my_project$ cd build && ctest
Test project .../my_project/build
    Start 1: HelloTest.BasicAssertions
1/1 Test #1: HelloTest.BasicAssertions ........   Passed    0.00 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.01 sec

Look at the sample code

✅ Formal Verification

  • 비용 많이 들어가
  • 아무 software나 증명할 수 XX
  • 타겟? system sw.. (os, distributed system, android..)

✅ Distributed System

❗️ 왜 중요?

❗️ 얻고싶은게 뭐?

✅ Q & A

  • Internal reference . .
  • 이력서 잘쓰기^^ 프로젝트에서 역할/경험?
  • Coding interview = = communication ! algorithm & 풀이방법
  • github : source code license 습관
  • ML ? python, C++ . . . keras . . . jax . . .
  • research & question