Skip to content

🧪 [testing improvement] Add tests for FFT mode setting and getters#269

Open
segin wants to merge 1 commit intomasterfrom
jules-test-fft-mode-2899678280063234222
Open

🧪 [testing improvement] Add tests for FFT mode setting and getters#269
segin wants to merge 1 commit intomasterfrom
jules-test-fft-mode-2899678280063234222

Conversation

@segin
Copy link
Copy Markdown
Owner

@segin segin commented Apr 8, 2026

🎯 What: The task required adding tests for the setFFTMode logic in src/core/fft.cpp, specifically targeting setFFTMode, getFFTMode, and getFFTModeName.
📊 Coverage: A new test case tests/test_fft_mode.cpp was written covering all valid enum cases (FFTMode::Original, FFTMode::Optimized, FFTMode::NeomatIn, FFTMode::NeomatOut). The test ensures these getters properly reflect state modifications. I also caught and resolved a missing <complex> header that caused build issues when including fft.h in isolation.
Result: Enhanced unit test coverage and confidence in the FFT codebase's state control logic. Tests were integrated into make check.


PR created automatically by Jules for task 2899678280063234222 started by @segin

Added test_fft_mode.cpp to test FFT::setFFTMode, FFT::getFFTMode, and FFT::getFFTModeName. Registered the test in tests/Makefile.am and added missing <complex> header to include/core/fft.h.

Co-authored-by: segin <480709+segin@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings April 8, 2026 03:56
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds unit coverage for FFT mode selection/state getters, and makes the FFT public header self-contained for isolated inclusion.

Changes:

  • Introduces a new unit test covering setFFTMode, getFFTMode, and getFFTModeName across all enum values.
  • Integrates the new test binary into make check.
  • Fixes missing standard library includes in include/core/fft.h (notably for <complex>).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/test_fft_mode.cpp New unit test verifying FFT mode setter + getters end-to-end
tests/Makefile.am Adds test_fft_mode to check_PROGRAMS so it runs in make check
include/core/fft.h Adds standard library headers to make the public header self-contained

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_fft_mode.cpp
* PsyMP3 is free software. You may redistribute and/or modify it under
* the terms of the ISC License <https://opensource.org/licenses/ISC>
*/

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test uses std::cout/std::cerr later but doesn’t directly include <iostream>. Relying on transitive includes (e.g., via test_framework.h) can make the test brittle if headers change. Add an explicit #include <iostream> in this file to ensure it compiles standalone.

Suggested change
#include <iostream>

Copilot uses AI. Check for mistakes.
Comment thread tests/test_fft_mode.cpp
Comment on lines +24 to +42
// Test Original mode
fft.setFFTMode(FFTMode::Original);
ASSERT_TRUE(fft.getFFTMode() == FFTMode::Original, "getFFTMode should return Original");
ASSERT_TRUE(fft.getFFTModeName() == "mat-og", "getFFTModeName should return mat-og");

// Test Optimized mode
fft.setFFTMode(FFTMode::Optimized);
ASSERT_TRUE(fft.getFFTMode() == FFTMode::Optimized, "getFFTMode should return Optimized");
ASSERT_TRUE(fft.getFFTModeName() == "vibe-1", "getFFTModeName should return vibe-1");

// Test NeomatIn mode
fft.setFFTMode(FFTMode::NeomatIn);
ASSERT_TRUE(fft.getFFTMode() == FFTMode::NeomatIn, "getFFTMode should return NeomatIn");
ASSERT_TRUE(fft.getFFTModeName() == "neomat-in", "getFFTModeName should return neomat-in");

// Test NeomatOut mode
fft.setFFTMode(FFTMode::NeomatOut);
ASSERT_TRUE(fft.getFFTMode() == FFTMode::NeomatOut, "getFFTMode should return NeomatOut");
ASSERT_TRUE(fft.getFFTModeName() == "neomat-out", "getFFTModeName should return neomat-out");
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test repeats the same pattern four times (set mode → assert enum → assert name). Consider table-driving this with a small array of {mode, expectedName, expectedModeLabel} and looping, so adding/removing modes becomes a one-line change and reduces the chance of copy/paste mistakes.

Suggested change
// Test Original mode
fft.setFFTMode(FFTMode::Original);
ASSERT_TRUE(fft.getFFTMode() == FFTMode::Original, "getFFTMode should return Original");
ASSERT_TRUE(fft.getFFTModeName() == "mat-og", "getFFTModeName should return mat-og");
// Test Optimized mode
fft.setFFTMode(FFTMode::Optimized);
ASSERT_TRUE(fft.getFFTMode() == FFTMode::Optimized, "getFFTMode should return Optimized");
ASSERT_TRUE(fft.getFFTModeName() == "vibe-1", "getFFTModeName should return vibe-1");
// Test NeomatIn mode
fft.setFFTMode(FFTMode::NeomatIn);
ASSERT_TRUE(fft.getFFTMode() == FFTMode::NeomatIn, "getFFTMode should return NeomatIn");
ASSERT_TRUE(fft.getFFTModeName() == "neomat-in", "getFFTModeName should return neomat-in");
// Test NeomatOut mode
fft.setFFTMode(FFTMode::NeomatOut);
ASSERT_TRUE(fft.getFFTMode() == FFTMode::NeomatOut, "getFFTMode should return NeomatOut");
ASSERT_TRUE(fft.getFFTModeName() == "neomat-out", "getFFTModeName should return neomat-out");
struct FFTModeCase {
FFTMode mode;
const char* expectedName;
};
const FFTModeCase cases[] = {
{FFTMode::Original, "mat-og"},
{FFTMode::Optimized, "vibe-1"},
{FFTMode::NeomatIn, "neomat-in"},
{FFTMode::NeomatOut, "neomat-out"},
};
for (const auto& testCase : cases) {
fft.setFFTMode(testCase.mode);
ASSERT_TRUE(fft.getFFTMode() == testCase.mode, "getFFTMode should return the mode that was set");
ASSERT_TRUE(fft.getFFTModeName() == testCase.expectedName, "getFFTModeName should return the expected mode name");
}

Copilot uses AI. Check for mistakes.
Comment thread tests/Makefile.am
test_fft_mode_SOURCES = test_fft_mode.cpp
test_fft_mode_LDADD = \
libtest_utilities.a \
../src/core/libpsymp3-core.a
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this Makefile, other test targets appear to append $(AM_LDFLAGS) in their *_LDADD blocks (even though it’s an unusual pattern). This new target doesn’t, which can lead to inconsistent link behavior (e.g., missing rpath, sanitizer/runtime flags, or platform-specific link options expected via that variable). Update test_fft_mode_LDADD to follow the same convention used by adjacent tests in this file.

Suggested change
../src/core/libpsymp3-core.a
../src/core/libpsymp3-core.a \
$(AM_LDFLAGS)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants