This commit is contained in:
2026-01-18 18:40:26 +00:00
commit 185e73da47
51 changed files with 14073 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
/**
* @file header.h
* @brief Sample header file for testing.
*/
#ifndef HEADER_H
#define HEADER_H
/**
* @brief Maximum buffer size.
*/
#define MAX_BUFFER_SIZE 1024
/**
* @brief Status codes for operations.
*/
typedef enum {
STATUS_OK = 0,
STATUS_ERROR = 1,
STATUS_NOT_FOUND = 2
} Status;
/**
* @brief Buffer structure for data storage.
*/
typedef struct {
char data[MAX_BUFFER_SIZE];
int length;
} Buffer;
/**
* @brief Initialize a buffer.
* @param buf Pointer to the buffer
*/
void buffer_init(Buffer* buf);
/**
* @brief Write data to the buffer.
* @param buf Pointer to the buffer
* @param data Data to write
* @param len Length of data
* @return Status code
*/
Status buffer_write(Buffer* buf, const char* data, int len);
/**
* @brief Read data from the buffer.
* @param buf Pointer to the buffer
* @param out Output buffer
* @param max_len Maximum length to read
* @return Number of bytes read
*/
int buffer_read(Buffer* buf, char* out, int max_len);
#endif /* HEADER_H */
+57
View File
@@ -0,0 +1,57 @@
/**
* @file valid.c
* @brief Sample C file for testing.
*/
#include <stdio.h>
#include <stdlib.h>
/**
* @brief A simple point structure.
*/
struct Point {
int x;
int y;
};
/**
* @brief Creates a new point.
* @param x The x coordinate
* @param y The y coordinate
* @return A new Point structure
*/
struct Point create_point(int x, int y) {
struct Point p;
p.x = x;
p.y = y;
return p;
}
/**
* @brief Calculates the distance from origin.
* @param p The point
* @return The squared distance from origin
*/
int distance_squared(struct Point p) {
return p.x * p.x + p.y * p.y;
}
/**
* @brief Prints a point to stdout.
* @param p The point to print
*/
void print_point(struct Point p) {
printf("Point(%d, %d)\n", p.x, p.y);
}
// Simple helper function
int add(int a, int b) {
return a + b;
}
int main(void) {
struct Point p = create_point(3, 4);
print_point(p);
printf("Distance squared: %d\n", distance_squared(p));
return 0;
}
+11
View File
@@ -0,0 +1,11 @@
package main
// This file contains intentional syntax errors for testing.
func broken( {
return
}
type Incomplete struct {
Name string
// Missing closing brace
+44
View File
@@ -0,0 +1,44 @@
package main
import "fmt"
// Server represents the main application server.
type Server struct {
Name string
Port int
}
// NewServer creates a new Server instance.
func NewServer(name string, port int) *Server {
return &Server{
Name: name,
Port: port,
}
}
// Start starts the server.
func (s *Server) Start() error {
fmt.Printf("Starting server %s on port %d\n", s.Name, s.Port)
return nil
}
// Config holds application configuration.
type Config struct {
Debug bool
Timeout int
}
const (
// DefaultPort is the default server port.
DefaultPort = 8080
)
var (
// Version is the application version.
Version = "1.0.0"
)
func main() {
srv := NewServer("main", DefaultPort)
srv.Start()
}
+29
View File
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test HTML File</title>
</head>
<body>
<div class="container mx-auto px-4">
<h1 class="text-3xl font-bold text-blue-600">Hello World</h1>
<p class="text-gray-700 mt-4">This is a test HTML file with Tailwind CSS classes.</p>
<div class="flex gap-4 mt-8">
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Primary Button
</button>
<button class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
Secondary Button
</button>
</div>
<ul class="list-disc list-inside mt-4">
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
</div>
</body>
</html>
+62
View File
@@ -0,0 +1,62 @@
"""
Sample Python module for testing.
"""
from typing import List, Optional
class DataProcessor:
"""Processes data records."""
def __init__(self, name: str):
"""
Initialize the processor.
Args:
name: The processor name
"""
self.name = name
self._records: List[dict] = []
def add_record(self, record: dict) -> None:
"""
Add a record to the processor.
Args:
record: The record to add
"""
self._records.append(record)
def process(self) -> List[dict]:
"""
Process all records.
Returns:
The processed records
"""
return [self._transform(r) for r in self._records]
def _transform(self, record: dict) -> dict:
"""Transform a single record."""
return {k.upper(): v for k, v in record.items()}
def calculate_sum(numbers: List[int]) -> int:
"""
Calculate the sum of numbers.
Args:
numbers: List of integers to sum
Returns:
The sum of all numbers
"""
return sum(numbers)
def find_maximum(values: List[int]) -> Optional[int]:
"""Find the maximum value in a list."""
return max(values) if values else None
DEFAULT_BATCH_SIZE = 100
+129
View File
@@ -0,0 +1,129 @@
import React, { useState, useEffect } from 'react';
interface ButtonProps {
variant?: 'primary' | 'secondary';
disabled?: boolean;
onClick?: () => void;
children: React.ReactNode;
}
/**
* A reusable button component with Tailwind CSS styling
*/
export const Button: React.FC<ButtonProps> = ({
variant = 'primary',
disabled = false,
onClick,
children
}) => {
const baseClasses = 'font-bold py-2 px-4 rounded transition-colors duration-200';
const variantClasses = {
primary: 'bg-blue-500 hover:bg-blue-700 text-white',
secondary: 'bg-gray-500 hover:bg-gray-700 text-white'
};
return (
<button
className={`${baseClasses} ${variantClasses[variant]} ${disabled ? 'opacity-50 cursor-not-allowed' : ''}`}
disabled={disabled}
onClick={onClick}
>
{children}
</button>
);
};
interface TodoItem {
id: number;
text: string;
completed: boolean;
}
/**
* Todo list component demonstrating React hooks and Tailwind
*/
export const TodoList: React.FC = () => {
const [todos, setTodos] = useState<TodoItem[]>([
{ id: 1, text: 'Learn React', completed: true },
{ id: 2, text: 'Learn TypeScript', completed: true },
{ id: 3, text: 'Build amazing apps', completed: false }
]);
const [inputValue, setInputValue] = useState('');
useEffect(() => {
console.log('Todos updated:', todos);
}, [todos]);
const addTodo = () => {
if (inputValue.trim()) {
const newTodo: TodoItem = {
id: Date.now(),
text: inputValue,
completed: false
};
setTodos([...todos, newTodo]);
setInputValue('');
}
};
const toggleTodo = (id: number) => {
setTodos(todos.map(todo =>
todo.id === id ? { ...todo, completed: !todo.completed } : todo
));
};
const deleteTodo = (id: number) => {
setTodos(todos.filter(todo => todo.id !== id));
};
return (
<div className="container mx-auto px-4 py-8 max-w-2xl">
<h1 className="text-3xl font-bold text-gray-800 mb-6">
My Todo List
</h1>
<div className="flex gap-2 mb-6">
<input
type="text"
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
onKeyPress={(e) => e.key === 'Enter' && addTodo()}
placeholder="Add a new todo..."
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
<Button onClick={addTodo}>Add</Button>
</div>
<ul className="space-y-2">
{todos.map(todo => (
<li
key={todo.id}
className="flex items-center gap-3 p-4 bg-white rounded-lg shadow-sm hover:shadow-md transition-shadow"
>
<input
type="checkbox"
checked={todo.completed}
onChange={() => toggleTodo(todo.id)}
className="w-5 h-5 text-blue-600 rounded focus:ring-2 focus:ring-blue-500"
/>
<span className={`flex-1 ${todo.completed ? 'line-through text-gray-400' : 'text-gray-700'}`}>
{todo.text}
</span>
<Button
variant="secondary"
onClick={() => deleteTodo(todo.id)}
>
Delete
</Button>
</li>
))}
</ul>
{todos.length === 0 && (
<div className="text-center py-12 text-gray-400">
No todos yet. Add one above!
</div>
)}
</div>
);
};
+53
View File
@@ -0,0 +1,53 @@
/**
* Represents a user in the system.
*/
interface User {
id: number;
name: string;
email: string;
}
/**
* Configuration options for the application.
*/
type Config = {
debug: boolean;
timeout: number;
};
/**
* Greeting service for handling user greetings.
*/
class GreetingService {
private prefix: string;
/**
* Creates a new GreetingService.
* @param prefix The greeting prefix
*/
constructor(prefix: string) {
this.prefix = prefix;
}
/**
* Greets a user.
* @param user The user to greet
* @returns The greeting message
*/
greet(user: User): string {
return `${this.prefix}, ${user.name}!`;
}
}
/**
* Formats a user for display.
* @param user The user to format
* @returns Formatted string
*/
function formatUser(user: User): string {
return `${user.name} <${user.email}>`;
}
const DEFAULT_TIMEOUT = 5000;
export { User, Config, GreetingService, formatUser, DEFAULT_TIMEOUT };
+76
View File
@@ -0,0 +1,76 @@
<template>
<div class="container mx-auto px-4 py-8">
<h1 class="text-3xl font-bold text-blue-600 mb-4">
{{ title }}
</h1>
<div v-if="showContent" class="bg-white shadow-md rounded-lg p-6">
<p class="text-gray-700 mb-4">{{ description }}</p>
<div class="flex gap-4 mt-4">
<button
@click="handlePrimary"
:class="['bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded', { 'opacity-50': isLoading }]"
:disabled="isLoading"
>
{{ primaryButtonText }}
</button>
<button
@click="handleSecondary"
class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded"
>
{{ secondaryButtonText }}
</button>
</div>
<ul v-for="item in items" :key="item.id" class="list-disc list-inside mt-4">
<li class="text-gray-600">{{ item.name }}</li>
</ul>
</div>
<div v-else class="text-center text-gray-500">
<p>No content to display</p>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
interface Item {
id: number;
name: string;
}
const title = ref('Vue Component with Tailwind');
const description = ref('This is a sample Vue 3 component using Composition API and Tailwind CSS');
const showContent = ref(true);
const isLoading = ref(false);
const items = ref<Item[]>([
{ id: 1, name: 'First item' },
{ id: 2, name: 'Second item' },
{ id: 3, name: 'Third item' },
]);
const primaryButtonText = computed(() => isLoading.value ? 'Loading...' : 'Primary Action');
const secondaryButtonText = ref('Secondary Action');
const handlePrimary = () => {
isLoading.value = true;
setTimeout(() => {
isLoading.value = false;
}, 2000);
};
const handleSecondary = () => {
console.log('Secondary button clicked');
};
</script>
<style scoped>
.container {
max-width: 1200px;
}
</style>