< Summary - Backend C Tests - Coverage Report (WSL)

Information
Class: stack_c
Assembly: src.backend.core.data_structures
File(s): ./src/backend/core/data_structures/stack.c
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 47
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 2/18/2026 - 10:50:55 PM Line coverage: 100% (22/22) Branch coverage: 75% (3/4) Total lines: 47 2/18/2026 - 10:50:55 PM Line coverage: 100% (22/22) Branch coverage: 75% (3/4) Total lines: 47

File(s)

./src/backend/core/data_structures/stack.c

#LineLine coverage
 1/* This file is a template for stack.c. Content will be filled by yagiz on 2025-12-29. */
 2#include <stdio.h>
 3#include "stack.h"
 4
 25void initStack(Stack *s) {
 26  s->top = 0;   // Start index
 27  s->count = 0; // No operations to undo yet
 28}
 9
 10// ADD NEW OPERATION (Circular Overwrite Logic)
 211void push(Stack *s, Operation op) {
 12  // 1. Write new element to "top"
 213  s->history[s->top] = op;
 214  printf("Operation Added (ID: %d) -> Stack Index: %d\n", op.operation_id, s->top);
 15  // 2. Advance top (Circular: 0, 1, 2, 3, 4 -> 0)
 216  s->top = (s->top + 1) % MAX_UNDO_LEVEL;
 17
 18  // 3. Increment count if not full.
 19  // If full (count == 5), do not increment.
 20  // Because we overwrote the oldest data, total count remains 5.
 221  if (s->count < MAX_UNDO_LEVEL) {
 222    s->count++;
 23  }
 224}
 25
 26// UNDO OPERATION
 327bool pop(Stack *s, Operation *outOp) {
 328  if (s->count == 0) {
 129    printf("ERROR: No operation to undo! (Stack Empty)\n");
 130    return false;
 31  }
 32
 33  // 1. Move Top BACK
 34  // WARNING: Negative modulo is tricky in C.
 35  // Formula: (top - 1 + MAX) % MAX
 236  s->top = (s->top - 1 + MAX_UNDO_LEVEL) % MAX_UNDO_LEVEL;
 37  // 2. Retrieve data
 238  *outOp = s->history[s->top];
 39  // 3. Decrement count
 240  s->count--;
 241  printf("Operation Undone: ID %d\n", outOp->operation_id);
 242  return true;
 43}
 44
 445int getUndoCount(Stack *s) {
 446  return s->count;
 47}

Methods/Properties