name: cpp-expert-tests
skill: cpp-expert
version: 1.0.0
cases:
  - id: raw-new-delete
    description: Should reject raw new/delete and recommend smart pointers with RAII
    prompt: "I'm allocating objects with new and calling delete in my class destructor. Is there a better way in modern C++?"
    expected:
      contains_any:
        - unique_ptr
        - shared_ptr
        - make_unique
        - RAII
        - smart pointer
        - destructor
        - Rule of Zero
      not_contains:
        - raw new is fine
      min_length: 80
    tags: [core, raii]

  - id: const-correctness
    description: Should recommend const on all non-mutating parameters and member functions
    prompt: When should I use const in C++? My code compiles without it.
    expected:
      contains_any:
        - const reference
        - const member function
        - const parameter
        - constexpr
        - "const&"
        - correctness
        - mutation
      min_length: 80
    tags: [core, const]

  - id: c-style-cast
    description: Should reject C-style casts and recommend named casts
    prompt: I need to cast a double to an int in C++. I'm using (int)value. Is that fine?
    expected:
      contains_any:
        - static_cast
        - reinterpret_cast
        - named cast
        - C-style cast
        - intent
        - explicit
        - dangerous
      min_length: 60
    tags: [core, safety]

  - id: undefined-behavior-sanitizers
    description: Should recommend enabling sanitizers in CI to catch undefined behavior
    prompt: My C++ code has subtle bugs that only appear in production. How can I catch undefined behavior earlier?
    expected:
      contains_any:
        - sanitizer
        - AddressSanitizer
        - asan
        - ubsan
        - UBSan
        - undefined behavior
        - "-fsanitize"
        - CI
      min_length: 80
    tags: [core, safety]

  - id: std-optional-over-pointer
    description: Should recommend std::optional instead of nullable pointers or sentinel values
    prompt: My function returns a pointer to a User if found, or nullptr if not found. Is there a better way?
    expected:
      contains_any:
        - std::optional
        - optional
        - "std::nullopt"
        - nullable
        - sentinel
        - has_value
        - value_or
      min_length: 60
    tags: [core, types]

  - id: vector-over-list
    description: Should recommend std::vector over std::list for general sequential data
    prompt: I need a data structure to store a sequence of objects that I iterate over frequently. Should I use std::list for fast insertion?
    expected:
      contains_any:
        - std::vector
        - cache
        - sequential
        - memory layout
        - contiguous
        - list
        - benchmark
        - profile
      min_length: 80
    tags: [core, performance]

  - id: coding-easy-raii-file
    description: "Coding challenge (easy): Write a RAII file handle wrapper"
    prompt: "Write a C++ RAII class called FileHandle that wraps a FILE* pointer. It should open the file in the constructor, close it in the destructor, be non-copyable but movable, and provide read/write methods. Use modern C++ idioms."
    expected:
      contains_any:
        - RAII
        - destructor
        - fclose
        - delete
        - move
        - noexcept
      contains:
        - class
      not_contains:
        - "I can't write"
      min_length: 100
    tags:
      - coding-easy

  - id: coding-medium-thread-safe-queue
    description: "Coding challenge (medium): Implement a thread-safe bounded queue"
    prompt: "Write a C++ thread-safe bounded queue using std::mutex and std::condition_variable. It should support push (blocks when full), pop (blocks when empty), try_push and try_pop (non-blocking), and a close method that wakes all waiters and prevents further operations. Make it a template class."
    expected:
      contains_any:
        - mutex
        - condition_variable
        - unique_lock
        - notify
        - wait
        - template
      contains:
        - class
      min_length: 200
    tags:
      - coding-medium

  - id: coding-hard-compile-time-fsm
    description: "Coding challenge (hard): Implement a compile-time validated state machine"
    prompt: "Write a C++ state machine framework using templates and constexpr that validates transitions at compile time. Define states and events as types. Invalid transitions should produce a compile error, not a runtime error. Support entry/exit actions per state and guard conditions on transitions. Use C++20 concepts where appropriate."
    expected:
      contains_any:
        - template
        - constexpr
        - concept
        - static_assert
        - transition
        - state
      contains:
        - struct
      min_length: 300
    tags:
      - coding-hard
