diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index efe2716267..cbc138fa9d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -24,6 +24,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(BUILD_GTEST)
add_subdirectory(googletest)
endif()
+add_subdirectory(compiletests)
add_subdirectory(unittests)
# turn on solution folder
diff --git a/tests/compiletests.run.cmd b/tests/compiletests.run.cmd
new file mode 100644
index 0000000000..6a41001144
--- /dev/null
+++ b/tests/compiletests.run.cmd
@@ -0,0 +1,55 @@
+setlocal
+set BUILD_BASE_DIR=%~dp1
+set SOURCE_DIR=%~dp0compiletests
+
+:: find generic tools
+if not defined CMD_VSWHERE call %~dp0..\tools\find-tools.bat
+
+set /a NUM_VSVERSION_NEXT=NUM_VSVERSION + 1
+
+if not exist "%CMD_CMAKE%" (
+ echo "no cmake found."
+ exit /b 1
+)
+
+if not exist "%CMD_NINJA%" (
+ set GENERATOR="%CMAKE_G_PARAM%"
+ set GENERATOR_OPTS=-A %PLATFORM% "-DCMAKE_CONFIGURATION_TYPES=Debug;Release"
+ set "MAKE_PROGRAM=%CMD_MSBUILD%"
+ set "BUILD_DIR=%BUILD_BASE_DIR%compiletests\%platform%"
+) else (
+ set GENERATOR=Ninja
+ set GENERATOR_OPTS=-DCMAKE_BUILD_TYPE=%CONFIGURATION%
+ set "MAKE_PROGRAM=%CMD_NINJA%"
+ set "BUILD_DIR=%BUILD_BASE_DIR%compiletests\%platform%\%configuration%"
+)
+
+mkdir %BUILD_DIR% > NUL 2>&1
+pushd %BUILD_DIR%
+
+call :run_cmake_configure || endlocal && exit /b 1
+
+endlocal && exit /b 0
+
+:run_cmake_configure
+call :find_cl_compiler
+
+:: replace back-slash to slash in the path.
+set CL_COMPILER=%CMD_CL:\=/%
+
+:: run cmake configuration.
+"%CMD_CMAKE%" -G %GENERATOR% ^
+ "-DCMAKE_MAKE_PROGRAM=%MAKE_PROGRAM%" ^
+ "-DCMAKE_C_COMPILER=%CL_COMPILER%" ^
+ "-DCMAKE_CXX_COMPILER=%CL_COMPILER%" ^
+ %GENERATOR_OPTS% ^
+ %SOURCE_DIR% ^
+ || endlocal && exit /b 1
+goto :EOF
+
+:find_cl_compiler
+for /f "usebackq delims=" %%a in (`where cl.exe`) do (
+ set "CMD_CL=%%a"
+ goto :EOF
+)
+goto :EOF
diff --git a/tests/compiletests.targets b/tests/compiletests.targets
new file mode 100644
index 0000000000..574e530cf6
--- /dev/null
+++ b/tests/compiletests.targets
@@ -0,0 +1,12 @@
+
+
+
+
+ $([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioVersion)', '^(\d+).*', '$1'))
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/compiletests/CMakeLists.txt b/tests/compiletests/CMakeLists.txt
new file mode 100644
index 0000000000..9eb013436e
--- /dev/null
+++ b/tests/compiletests/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.12)
+
+enable_language(CXX)
+
+set( SAKURA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../sakura_core)
+set( SAKURA_DEFINITIONS -D_DEBUG -D_UNICODE -DUNICODE -D_WIN32_WINNT=_WIN32_WINNT_WIN7)
+
+# コンパイルテスト実行関数
+function( compile_test TEST_TEMPLATE TEST_BODY TEST_DESCRIPTION TEST_NAME )
+ message( STATUS "Checking ${TEST_NAME}" )
+
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEST_TEMPLATE}
+ ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.cpp
+ NEWLINE_STYLE WIN32
+ )
+
+ try_compile(FAILED_TO_TEST ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.cpp
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${SAKURA_SOURCE_DIR}"
+ COMPILE_DEFINITIONS ${SAKURA_DEFINITIONS}
+ CXX_STANDARD 17
+ CXX_STANDARD_REQUIRED ON
+ CXX_EXTENSIONS OFF
+ )
+
+ if (NOT FAILED_TO_TEST)
+ message( STATUS "Checking ${TEST_NAME} - done" )
+ else()
+ message( FATAL_ERROR "Checking ${TEST_NAME} - Failed." )
+ endif (NOT FAILED_TO_TEST)
+endfunction( compile_test )
+
+# コンパイルテストの定義
+compile_test( clayoutint_test.cpp.in "a += b;" "CLayoutInt に CLogicIntを加算代入することはできない" clayoutint_can_not_be_additive_assigned_from_clogicint )
+compile_test( clayoutint_test.cpp.in "a -= b;" "CLayoutInt に CLogicIntを減算代入することはできない" clayoutint_can_not_be_subtractive_assigned_from_clogicint )
+compile_test( clayoutint_test.cpp.in "a = a + b;" "CLayoutInt と CLogicIntを加算することはできない" clayoutint_can_not_be_added_by_clogicint )
+compile_test( clayoutint_test.cpp.in "a = a - b;" "CLayoutInt から CLogicIntを減算することはできない" clayoutint_can_not_be_subtracted_by_clogicint )
+compile_test( clayoutint_test.cpp.in "a = b;" "CLayoutInt に CLogicIntを代入することはできない" clayoutint_can_not_be_assigned_from_clogicint )
+compile_test( clayoutint_test.cpp.in "a < b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_less_than )
+compile_test( clayoutint_test.cpp.in "a <= b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_less_or_equal )
+compile_test( clayoutint_test.cpp.in "a > b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_greater_than )
+compile_test( clayoutint_test.cpp.in "a >= b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_greater_or_equal )
+compile_test( clayoutint_test.cpp.in "a == b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_equal )
+compile_test( clayoutint_test.cpp.in "a != b;" "CLayoutInt と CLogicIntを比較することはできない" clayoutint_can_not_be_compare_with_clogicint_not_equal )
+compile_test( clayoutint_test.cpp.in "int c = a;" "CLayoutInt は キャストなしでint型に代入することはできない" clayoutint_can_not_be_assigned_to_int )
diff --git a/tests/compiletests/clayoutint_test.cpp.in b/tests/compiletests/clayoutint_test.cpp.in
new file mode 100644
index 0000000000..d9e77418b5
--- /dev/null
+++ b/tests/compiletests/clayoutint_test.cpp.in
@@ -0,0 +1,49 @@
+/*! @file */
+/*
+ Copyright (C) 2018-2020 Sakura Editor Organization
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented;
+ you must not claim that you wrote the original software.
+ If you use this software in a product, an acknowledgment
+ in the product documentation would be appreciated but is
+ not required.
+
+ 2. Altered source versions must be plainly marked as such,
+ and must not be misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source
+ distribution.
+*/
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif /* #ifndef NOMINMAX */
+
+#include
+#include
+
+#ifndef USE_STRICT_INT
+#define USE_STRICT_INT
+#endif /* #ifndef USE_STRICT_INT */
+
+#include "basis/SakuraBasis.h"
+
+/*!
+ * @brief テンプレートのテスト
+ * このファイルはビルドエラーになる
+ */
+void main()
+{
+ CLayoutInt a( 1 );
+ CLogicInt b( 2 );
+
+ //${TEST_DESCRIPTION}
+ ${TEST_BODY}
+}
diff --git a/tests/unittests/test-clayoutint.cpp b/tests/unittests/test-clayoutint.cpp
index db960fcb95..b4c3b9453f 100644
--- a/tests/unittests/test-clayoutint.cpp
+++ b/tests/unittests/test-clayoutint.cpp
@@ -96,7 +96,7 @@ TEST( CLayoutInt, OperatorRemainder )
{
// コメントアウトの組み合わせは未実装。
CLayoutInt a( 2 ), b( 3 ), c( 8 );
-
+
EXPECT_TRUE( a == c % b );
EXPECT_TRUE( a == c % 3 );
//EXPECT_TRUE( a == 6 % b );
diff --git a/tests/unittests/tests1.vcxproj b/tests/unittests/tests1.vcxproj
index a1832d940e..e2661f6600 100644
--- a/tests/unittests/tests1.vcxproj
+++ b/tests/unittests/tests1.vcxproj
@@ -40,6 +40,7 @@
$(Platform)\$(Configuration)\
+
$(SolutionDir)sakura_core;%(AdditionalIncludeDirectories)