Files
repomix-mirror/tests/core/treeSitter/parseFile.cpp.test.ts
Kazuki Yamada b7fe6f25c5 fix(lint): resolve all oxlint warnings for code quality
- Remove unused imports across 67 files (RepomixConfigMerged, QueryCapture, etc.)
- Fix unused parameters by prefixing with underscore (_context, _index, etc.)
- Remove unused catch parameters using modern JavaScript syntax
- Fix require-yield warnings in generator functions
- Remove unused variables and interface declarations
- Add oxlint configuration to ignore integration test fixtures

Resolves 144 linting warnings while preserving all functionality.
All 743 tests continue to pass. Code quality significantly improved.
2025-08-24 18:25:08 +09:00

101 lines
3.0 KiB
TypeScript

import { describe, expect, test } from 'vitest';
import { parseFile } from '../../../src/core/treeSitter/parseFile.js';
import { createMockConfig } from '../../testing/testUtils.js';
describe('parseFile for C/C++', () => {
// Test for C++
test('should parse C++ correctly', async () => {
const fileContent = `
// Main entry point
/* The main function that outputs
* a greeting to the world
*/
int main() {
std::cout << "Hello, world!"; return 0;
}
`;
const filePath = 'dummy.cpp';
const config = {};
const result = await parseFile(fileContent, filePath, createMockConfig(config));
expect(typeof result).toBe('string');
const expectContents = [
'// Main entry point',
'/* The main function that outputs',
'* a greeting to the world',
'*/',
'int main() {',
];
for (const expectContent of expectContents) {
expect(result).toContain(expectContent);
}
});
test('should parse C++ header correctly', async () => {
const fileContent = `
// Header file main function
/* This header declares the main function
* for the program entry point
*/
int main() { std::cout << "Hello, world!"; return 0; }
`;
const filePath = 'dummy.hpp';
const config = {};
const result = await parseFile(fileContent, filePath, createMockConfig(config));
expect(typeof result).toBe('string');
const expectContents = ['main', 'Header file main function', 'This header declares the main function'];
for (const expectContent of expectContents) {
expect(result).toContain(expectContent);
}
});
// Test for C
test('should parse C correctly', async () => {
const fileContent = `
/* The main function
* Prints a greeting to stdout
*/
// Entry point of the program
int main() { printf("Hello, world!"); return 0; }
`;
const filePath = 'dummy.c';
const config = {};
const result = await parseFile(fileContent, filePath, createMockConfig(config));
expect(typeof result).toBe('string');
const expectContents = ['main', 'The main function', 'Prints a greeting to stdout', 'Entry point of the program'];
for (const expectContent of expectContents) {
expect(result).toContain(expectContent);
}
});
test('should parse C header correctly', async () => {
const fileContent = `
/* Header file for main function
* Declares the program entry point
*/
// Main function prototype
int main() { printf("Hello, world!"); return 0; }
`;
const filePath = 'dummy.h';
const config = {};
const result = await parseFile(fileContent, filePath, createMockConfig(config));
expect(typeof result).toBe('string');
const expectContents = [
'main',
'Header file for main function',
'Declares the program entry point',
'Main function prototype',
];
for (const expectContent of expectContents) {
expect(result).toContain(expectContent);
}
});
});