Step 228: Add prompt templates
This commit is contained in:
@@ -1166,6 +1166,8 @@ add_executable(step226_test tests/step226_test.cpp)
|
||||
target_include_directories(step226_test PRIVATE src)
|
||||
add_executable(step227_test tests/step227_test.cpp)
|
||||
target_include_directories(step227_test PRIVATE src)
|
||||
add_executable(step228_test tests/step228_test.cpp)
|
||||
target_include_directories(step228_test PRIVATE src)
|
||||
add_executable(step213_test tests/step213_test.cpp)
|
||||
target_include_directories(step213_test PRIVATE src)
|
||||
target_link_libraries(step213_test PRIVATE nlohmann_json::nlohmann_json)
|
||||
|
||||
40
editor/tests/step228_test.cpp
Normal file
40
editor/tests/step228_test.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Step 228: Prompt engineering templates.
|
||||
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
static std::string readFile(const std::string& path) {
|
||||
std::ifstream f(path);
|
||||
if (!f.is_open()) return {};
|
||||
return std::string((std::istreambuf_iterator<char>(f)),
|
||||
std::istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
static void assertContains(const std::string& text, const std::string& needle) {
|
||||
assert(text.find(needle) != std::string::npos);
|
||||
}
|
||||
|
||||
int main() {
|
||||
const std::vector<std::string> prompts = {
|
||||
"../tools/prompts/annotate_module.prompt",
|
||||
"../tools/prompts/cross_language.prompt",
|
||||
"../tools/prompts/code_review.prompt",
|
||||
"../tools/prompts/refactor.prompt",
|
||||
"../tools/prompts/security.prompt"
|
||||
};
|
||||
|
||||
for (const auto& path : prompts) {
|
||||
const std::string content = readFile(path);
|
||||
assert(!content.empty());
|
||||
assertContains(content, "system:");
|
||||
assertContains(content, "user:");
|
||||
assertContains(content, "expected_tools:");
|
||||
assertContains(content, "success_criteria:");
|
||||
assertContains(content, "{{");
|
||||
}
|
||||
|
||||
printf("step228_test: all assertions passed\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user