initial commit with working version

This commit is contained in:
Patryk Hegenberg 2025-11-28 15:59:06 +01:00
commit 7e4dd30599
235 changed files with 23683 additions and 0 deletions

View file

@ -0,0 +1,89 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:slrpg_app/src/shared/domain/logic/plate_calculator.dart';
void main() {
group('PlateCalculator', () {
final plates = [20.0, 10.0, 5.0, 2.5, 1.25];
final bands = {'Green': 20.0, 'Blue': 10.0};
test('Calculates barbell plates correctly', () {
// Target 70kg, Bar 20kg -> Need 50kg -> 25kg per side -> 20 + 5
final result = PlateCalculator.calculate(
targetWeight: 70.0,
barWeight: 20.0,
availablePlates: plates,
isTwoSided: true,
);
expect(result.success, true);
expect(result.plateConfiguration, [20.0, 5.0]);
expect(result.totalAchieved, 70.0);
});
test('Calculates belt weight correctly (One Sided)', () {
// Need 30kg added -> 20 + 10
final result = PlateCalculator.calculate(
targetWeight: 110.0, // 80 BW + 30 Added
barWeight: 80.0, // BW
availablePlates: plates,
isTwoSided: false,
);
expect(result.success, true);
expect(result.plateConfiguration, [20.0, 10.0]);
expect(result.totalAchieved, 110.0);
});
test('Band Selection: Correct band chosen', () {
// Need -10kg support
final result = PlateCalculator.calculate(
targetWeight: 70.0,
barWeight: 80.0, // BW
availablePlates: plates,
availableBands: bands,
isTwoSided: false,
);
expect(result.success, true);
expect(result.plateConfiguration, isEmpty);
expect(result.bandAssistance, 'Blue'); // 10kg band
expect(result.totalAchieved, 70.0);
});
test('Smart Switch: Bodyweight is better than oversized band', () {
// Need -2kg support. Smallest band is 10kg.
// With band: -10kg (8kg error). Without band: 0kg (2kg error).
// Should choose Bodyweight Only.
final result = PlateCalculator.calculate(
targetWeight: 78.0,
barWeight: 80.0,
availablePlates: plates,
availableBands: {'BigBand': 10.0},
isTwoSided: false,
);
expect(result.success, true);
expect(result.bandAssistance, null); // No band!
expect(result.message, contains('Bodyweight Only'));
});
test('Rounding Logic handles uneven weights', () {
// Need 9kg. Smallest plate 1.25.
// 9 / 1.25 = 7.2. Should round to 7 * 1.25 = 8.75kg or 8 * 1.25 = 10kg.
// 8.75 is closer (0.25 diff) than 10 (1.0 diff).
final result = PlateCalculator.calculate(
targetWeight: 29.0,
barWeight: 20.0,
availablePlates: [1.25], // Only small plates
isTwoSided: false, // Belt
);
// Needed 9.0. Found 8.75 (7x 1.25). Total 28.75.
expect(result.success, true);
expect(result.totalAchieved, 28.75);
expect(result.plateConfiguration.length, 7);
});
});
}

View file

@ -0,0 +1,96 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:slrpg_app/src/shared/domain/logic/wendler_calculator.dart';
void main() {
group('WendlerCalculator', () {
const double bodyweight = 80.0;
test('Week 1 (5/5/5+) generates correct percentages and reps', () {
// Setup: Squat TM 100kg
final sets = WendlerCalculator.generateSets(
week: 1,
trainingMax: 100.0,
exerciseType: ExerciseType.squat,
currentBodyweight: bodyweight,
);
expect(sets.length, 3);
// Set 1: 65% = 65kg
expect(sets[0].targetPercentage, 65);
expect(sets[0].targetWeightTotal, 65.0);
expect(sets[0].repsTarget, 5);
expect(sets[0].isAmrap, false);
// Set 2: 75% = 75kg
expect(sets[1].targetPercentage, 75);
expect(sets[1].targetWeightTotal, 75.0);
expect(sets[1].repsTarget, 5);
// Set 3: 85% = 85kg (AMRAP)
expect(sets[2].targetPercentage, 85);
expect(sets[2].targetWeightTotal, 85.0);
expect(sets[2].repsTarget, 5);
expect(sets[2].isAmrap, true);
});
test('Squat rounding works (2.5kg steps)', () {
// 65% of 105kg = 68.25kg -> Should round down to 67.5kg
final sets = WendlerCalculator.generateSets(
week: 1,
trainingMax: 105.0,
exerciseType: ExerciseType.squat,
currentBodyweight: bodyweight,
);
expect(sets[0].targetWeightTotal, 67.5);
});
test('Pullup calculation considers bodyweight', () {
// TM 100kg, BW 80kg -> Target 65kg (65%)
// Since Target (65) < BW (80), plate weight should be 0 (assistance/bodyweight logic handles negative)
// But WendlerCalculator returns total system weight in targetWeightTotal
final sets = WendlerCalculator.generateSets(
week: 1,
trainingMax: 100.0,
exerciseType: ExerciseType.pullup,
currentBodyweight: bodyweight,
);
expect(sets[0].targetWeightTotal, 65.0); // System weight
expect(sets[0].plateWeight, 0.0); // No added weight
});
test('Pullup calculation with added weight', () {
// TM 150kg -> 65% = 97.5kg
// BW 80kg -> Added weight = 17.5kg
final sets = WendlerCalculator.generateSets(
week: 1,
trainingMax: 150.0,
exerciseType: ExerciseType.pullup,
currentBodyweight: bodyweight,
);
expect(sets[0].targetWeightTotal, 97.5);
expect(sets[0].plateWeight, 17.5);
});
test('FSL generates 5x5 at 65%', () {
final fslSets = WendlerCalculator.generateFSLSets(
trainingMax: 100.0,
exerciseType: ExerciseType.squat,
currentBodyweight: bodyweight,
);
expect(fslSets.length, 5);
for (var set in fslSets) {
expect(set.targetPercentage, 65);
expect(set.targetWeightTotal, 65.0);
expect(set.repsTarget, 5);
expect(set.isAmrap, false);
}
});
});
}