// 10 // / \ // 6 14 // /\ /\ // 4 8 12 16 void Test1() { int data[] = {4, 8, 6, 12, 16, 14, 10}; Test("Test1", data, sizeof(data)/sizeof(int), true); }
int _tmain(int argc, _TCHAR* argv[]) { Test(1, 1); Test(2, 2); Test(3, 3); Test(4, 4); Test(5, 5); Test(6, 6); Test(7, 8); Test(8, 9); Test(9, 10); Test(10, 12); Test(11, 15); Test(1500, 859963392); Test(0, 0); return 0; }
// Test out the heap implementation -- with max heap int main(int argc, char** argv) { int i, j; int n; Int* A[20]; Int* B[20]; Int C[10] = {73, 6, 57, 88, 60, 34, 83, 72, 48, 85}; heap<Int*, maxIntsCompare> BH(B, 0, 20); heap<Int, maxIntCompare> Test(C, 10, 10); if (argc != 2) { cout << "Usage: heap <heapsize>\n"; exit(-1); } n = atoi(argv[1]); if (n > 20) { cout << "heap size " << n << " too big.\n"; exit(-1); } Randomize(); for (i=0; i<n; i++) A[i] = new Int(i); permute(A, n); cout << "Initial values:\n"; for (i=0; i<n; i++) { cout << A[i] << " "; if (i == 9) cout << "\n"; } cout << "\n\n"; for (i=0; i<n; i++) BH.insert(A[i]); for (i=0; i<BH.size(); i++) { cout << B[i] << " "; if (i == 9) cout << "\n"; } cout << "\n\n"; heap<Int*, maxIntsCompare> AH(A, n, 20); Int* AHval = NULL; for (i=0; i<AH.size(); i++) { cout << A[i] << " "; if (i == 9) cout << "\n"; } cout << "\n\n"; AHval = AH.removefirst(); cout << "Max value: " << AHval << "\n"; for (i=0; i<AH.size(); i++) { cout << A[i] << " "; if (i == 9) cout << "\n"; } cout << "\n\n"; AHval = AH.removefirst(); cout << "Max value: " << AHval << "\n"; for (i=0; i<AH.size(); i++) { cout << A[i] << " "; if (i == 9) cout << "\n"; } cout << "\n\n"; AHval = AH.remove(2); cout << "Remove value: " << AHval << "\n"; for (i=0; i<AH.size(); i++) { cout << A[i] << " "; if (i == 9) cout << "\n"; } cout << "\n"; for (i=0; i<10; i++) cout << C[i] << " "; cout << "\n"; Int Testval; for (j=0; j<10; j++) { Testval = Test.removefirst(); for (i=0; i<10; i++) cout << C[i] << " "; cout << "\n"; } return 0; }
// empty string void Test4() { Test("Test4", "", ""); }
bool IntrBox3Box3<Real>::Test (Real tmax, const Vector3<Real>& velocity0, const Vector3<Real>& velocity1) { if (velocity0 == velocity1) { if (Test()) { mContactTime = (Real)0; return true; } return false; } // Cutoff for cosine of angles between box axes. This is used to catch // the cases when at least one pair of axes are parallel. If this // happens, there is no need to include the cross-product axes for // separation. const Real cutoff = (Real)1 - Math<Real>::ZERO_TOLERANCE; bool existsParallelPair = false; // convenience variables const Vector3<Real>* A = mBox0->Axis; const Vector3<Real>* B = mBox1->Axis; const Real* EA = mBox0->Extent; const Real* EB = mBox1->Extent; Vector3<Real> D = mBox1->Center - mBox0->Center; Vector3<Real> W = velocity1 - velocity0; Real C[3][3]; // matrix C = A^T B, c_{ij} = Dot(A_i,B_j) Real AbsC[3][3]; // |c_{ij}| Real AD[3]; // Dot(A_i,D) Real AW[3]; // Dot(A_i,W) Real min0, max0, min1, max1, center, radius, speed; int i, j; mContactTime = (Real)0; Real tlast = Math<Real>::MAX_REAL; // axes C0+t*A[i] for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { C[i][j] = A[i].Dot(B[j]); AbsC[i][j] = Math<Real>::FAbs(C[i][j]); if (AbsC[i][j] > cutoff) { existsParallelPair = true; } } AD[i] = A[i].Dot(D); AW[i] = A[i].Dot(W); min0 = -EA[i]; max0 = +EA[i]; radius = EB[0]*AbsC[i][0] + EB[1]*AbsC[i][1] + EB[2]*AbsC[i][2]; min1 = AD[i] - radius; max1 = AD[i] + radius; speed = AW[i]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } } // axes C0+t*B[i] for (i = 0; i < 3; ++i) { radius = EA[0]*AbsC[0][i] + EA[1]*AbsC[1][i] + EA[2]*AbsC[2][i]; min0 = -radius; max0 = +radius; center = B[i].Dot(D); min1 = center - EB[i]; max1 = center + EB[i]; speed = W.Dot(B[i]); if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } } // At least one pair of box axes was parallel, so the separation is // effectively in 2D where checking the "edge" normals is sufficient for // the separation of the boxes. if (existsParallelPair) { return true; } // axis C0+t*A0xB0 radius = EA[1]*AbsC[2][0] + EA[2]*AbsC[1][0]; min0 = -radius; max0 = +radius; center = AD[2]*C[1][0] - AD[1]*C[2][0]; radius = EB[1]*AbsC[0][2] + EB[2]*AbsC[0][1]; min1 = center - radius; max1 = center + radius; speed = AW[2]*C[1][0] - AW[1]*C[2][0]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } // axis C0+t*A0xB1 radius = EA[1]*AbsC[2][1] + EA[2]*AbsC[1][1]; min0 = -radius; max0 = +radius; center = AD[2]*C[1][1] - AD[1]*C[2][1]; radius = EB[0]*AbsC[0][2] + EB[2]*AbsC[0][0]; min1 = center - radius; max1 = center + radius; speed = AW[2]*C[1][1] - AW[1]*C[2][1]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } // axis C0+t*A0xB2 radius = EA[1]*AbsC[2][2] + EA[2]*AbsC[1][2]; min0 = -radius; max0 = +radius; center = AD[2]*C[1][2] - AD[1]*C[2][2]; radius = EB[0]*AbsC[0][1] + EB[1]*AbsC[0][0]; min1 = center - radius; max1 = center + radius; speed = AW[2]*C[1][2] - AW[1]*C[2][2]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } // axis C0+t*A1xB0 radius = EA[0]*AbsC[2][0] + EA[2]*AbsC[0][0]; min0 = -radius; max0 = +radius; center = AD[0]*C[2][0] - AD[2]*C[0][0]; radius = EB[1]*AbsC[1][2] + EB[2]*AbsC[1][1]; min1 = center - radius; max1 = center + radius; speed = AW[0]*C[2][0] - AW[2]*C[0][0]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } // axis C0+t*A1xB1 radius = EA[0]*AbsC[2][1] + EA[2]*AbsC[0][1]; min0 = -radius; max0 = +radius; center = AD[0]*C[2][1] - AD[2]*C[0][1]; radius = EB[0]*AbsC[1][2] + EB[2]*AbsC[1][0]; min1 = center - radius; max1 = center + radius; speed = AW[0]*C[2][1] - AW[2]*C[0][1]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } // axis C0+t*A1xB2 radius = EA[0]*AbsC[2][2] + EA[2]*AbsC[0][2]; min0 = -radius; max0 = +radius; center = AD[0]*C[2][2] - AD[2]*C[0][2]; radius = EB[0]*AbsC[1][1] + EB[1]*AbsC[1][0]; min1 = center - radius; max1 = center + radius; speed = AW[0]*C[2][2] - AW[2]*C[0][2]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } // axis C0+t*A2xB0 radius = EA[0]*AbsC[1][0] + EA[1]*AbsC[0][0]; min0 = -radius; max0 = +radius; center = AD[1]*C[0][0] - AD[0]*C[1][0]; radius = EB[1]*AbsC[2][2] + EB[2]*AbsC[2][1]; min1 = center - radius; max1 = center + radius; speed = AW[1]*C[0][0] - AW[0]*C[1][0]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } // axis C0+t*A2xB1 radius = EA[0]*AbsC[1][1] + EA[1]*AbsC[0][1]; min0 = -radius; max0 = +radius; center = AD[1]*C[0][1] - AD[0]*C[1][1]; radius = EB[0]*AbsC[2][2] + EB[2]*AbsC[2][0]; min1 = center - radius; max1 = center + radius; speed = AW[1]*C[0][1] - AW[0]*C[1][1]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } // axis C0+t*A2xB2 radius = EA[0]*AbsC[1][2] + EA[1]*AbsC[0][2]; min0 = -radius; max0 = +radius; center = AD[1]*C[0][2] - AD[0]*C[1][2]; radius = EB[0]*AbsC[2][1] + EB[1]*AbsC[2][0]; min1 = center - radius; max1 = center + radius; speed = AW[1]*C[0][2] - AW[0]*C[1][2]; if (IsSeparated(min0, max0, min1, max1, speed, tmax, tlast)) { return false; } return true; }
BOOLEAN main() { return Test(); }
// Only blanks void Test5() { char input[] = " "; char expected[] = " "; Test("Test5", input, expected); }
int main(int argc, char **argv, char **env) { Verilated::commandArgs(argc, argv); Test test = Test(argv[0]); Vcore_id_module* top = new Vcore_id_module; top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should not be enabled", !top->output_enable_o); top->output_enable_i = 1; top->clk_i = 1; top->eval(); top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should not be enabled", !top->output_enable_o); top->core_selection_i = 42; top->save_selection_i = 1; top->output_enable_i = 0; top->clk_i = 1; top->eval(); top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should not be enabled", !top->output_enable_o); top->core_selection_i = 0; top->save_selection_i = 0; top->output_enable_i = 1; top->clk_i = 1; top->eval(); top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should be enabled", top->output_enable_o); top->core_selection_i = 0; top->save_selection_i = 0; top->output_enable_i = 0; top->clk_i = 1; top->eval(); top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should not be enabled", !top->output_enable_o); top->core_selection_i = 12; top->save_selection_i = 1; top->output_enable_i = 0; top->clk_i = 1; top->eval(); top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should not be enabled", !top->output_enable_o); top->core_selection_i = 0; top->save_selection_i = 0; top->output_enable_i = 1; top->clk_i = 1; top->eval(); top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should NOT be enabled", !top->output_enable_o); top->core_selection_i = 42; top->save_selection_i = 1; top->output_enable_i = 0; top->clk_i = 1; top->eval(); top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should not be enabled", !top->output_enable_o); top->core_selection_i = 0; top->save_selection_i = 0; top->output_enable_i = 1; top->clk_i = 1; top->eval(); top->clk_i = 0; top->eval(); test.check("Core ID Output should be 42", top->core_id_o == 42); test.check("Output should be enabled", top->output_enable_o); delete top; test.report(); exit(0); }
int _tmain(int argc, _TCHAR* argv[]) { Test(0, 0); Test(1, 1); Test(2, 1); Test(3, 2); Test(4, 3); Test(5, 5); Test(6, 8); Test(7, 13); Test(8, 21); Test(9, 34); Test(10, 55); return 0; }
const boost::bimap<ribi::foam::PatchFieldType,std::string> ribi::foam::PatchFieldTypes::CreateMap() { #ifndef NDEBUG Test(); #endif boost::bimap<PatchFieldType,std::string> m; m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::advective,"advective")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::alphaSgsJayatillekeWallFunction,"alphaSgsJayatillekeWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::alphaSgsWallFunction,"alphaSgsWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::alphatJayatillekeWallFunction,"alphatJayatillekeWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::alphatWallFunction,"alphatWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::buoyantPressure,"buoyantPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::calculated,"calculated")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::codedFixedValue,"codedFixedValue")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::codedMixed,"codedMixed")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_epsilonWallFunction,"compressible_epsilonWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_kqRWallFunction,"compressible_kqRWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_omegaWallFunction,"compressible_omegaWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_temperatureThermoBaffle1D_constSolidThermoPhysics,"compressible_temperatureThermoBaffle1D_constSolidThermoPhysics")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_temperatureThermoBaffle1D_expoSolidThermoPhysics,"compressible_temperatureThermoBaffle1D_expoSolidThermoPhysics")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_turbulentHeatFluxTemperature,"compressible_turbulentHeatFluxTemperature")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_turbulentMixingLengthDissipationRateInlet,"compressible_turbulentMixingLengthDissipationRateInlet")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_turbulentMixingLengthFrequencyInlet,"compressible_turbulentMixingLengthFrequencyInlet")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_turbulentTemperatureCoupledBaffle,"compressible_turbulentTemperatureCoupledBaffle")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_turbulentTemperatureCoupledBaffleMixed,"compressible_turbulentTemperatureCoupledBaffleMixed")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::compressible_turbulentTemperatureRadCoupledMixed,"compressible_turbulentTemperatureRadCoupledMixed")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::cyclic,"cyclic")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::cyclicAMI,"cyclicAMI")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::cyclicSlip,"cyclicSlip")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::directionMixed,"directionMixed")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::empty,"empty")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::externalWallHeatFluxTemperature,"externalWallHeatFluxTemperature")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fan,"fan")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fanPressure,"fanPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fixedEnthalpy,"fixedEnthalpy")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fixedFluxPressure,"fixedFluxPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fixedGradient,"fixedGradient")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fixedInternalEnergy,"fixedInternalEnergy")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fixedInternalValue,"fixedInternalValue")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fixedPressureCompressibleDensity,"fixedPressureCompressibleDensity")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::fixedValue,"fixedValue")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::freestream,"freestream")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::freestreamPressure,"freestreamPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::gradientEnthalpy,"gradientEnthalpy")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::gradientInternalEnergy,"gradientInternalEnergy")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::htcConvection,"htcConvection")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::inletOutlet,"inletOutlet")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::inletOutletTotalTemperature,"inletOutletTotalTemperature")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mapped,"mapped")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mappedField,"mappedField")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mappedFixedInternalValue,"mappedFixedInternalValue")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mappedFixedPushedInternalValue,"mappedFixedPushedInternalValue")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mixed,"mixed")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mixedEnthalpy,"mixedEnthalpy")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mixedInternalEnergy,"mixedInternalEnergy")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::muSgsUSpaldingWallFunction,"muSgsUSpaldingWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::multiphaseFixedFluxPressure,"multiphaseFixedFluxPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mutLowReWallFunction,"mutLowReWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mutURoughWallFunction,"mutURoughWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mutUSpaldingWallFunction,"mutUSpaldingWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mutUWallFunction,"mutUWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mutkRoughWallFunction,"mutkRoughWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::mutkWallFunction,"mutkWallFunction")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::nonuniformTransformCyclic,"nonuniformTransformCyclic")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::oscillatingFixedValue,"oscillatingFixedValue")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::outletInlet,"outletInlet")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::outletMappedUniformInlet,"outletMappedUniformInlet")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::partialSlip,"partialSlip")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::patch,"patch")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::phaseHydrostaticPressure,"phaseHydrostaticPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::processor,"processor")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::processorCyclic,"processorCyclic")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::rotatingTotalPressure,"rotatingTotalPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::sliced,"sliced")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::slip,"slip")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::symmetryPlane,"symmetryPlane")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::syringePressure,"syringePressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::timeVaryingMappedFixedValue,"timeVaryingMappedFixedValue")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::totalFlowRateAdvectiveDiffusive,"totalFlowRateAdvectiveDiffusive")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::totalPressure,"totalPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::totalTemperature,"totalTemperature")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::turbulentInlet,"turbulentInlet")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::turbulentIntensityKineticEnergyInlet,"turbulentIntensityKineticEnergyInlet")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::uniformDensityHydrostaticPressure,"uniformDensityHydrostaticPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::uniformFixedValue,"uniformFixedValue")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::uniformTotalPressure,"uniformTotalPressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::wallHeatTransfer,"wallHeatTransfer")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::waveSurfacePressure,"waveSurfacePressure")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::waveTransmissive,"waveTransmissive")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::wedge,"wedge")); m.insert(boost::bimap<PatchFieldType,std::string>::value_type(PatchFieldType::zeroGradient,"zeroGradient")); return m; }
std::string PropertyParser::parseType(bool SupressDiagnostics) { std::string Result; bool HasConst = Test(clang::tok::kw_const); bool HasVolatile = Test(clang::tok::kw_volatile); bool NoTemplates = true; Test(clang::tok::kw_enum) || Test(clang::tok::kw_class) || Test(clang::tok::kw_struct); if (Test(clang::tok::kw_unsigned)) { Result += parseUnsigned(); } else if (Test(clang::tok::kw_signed)) { Result += "signed"; while (true) { switch(+CurrentTok.getKind()) { case clang::tok::kw_int: case clang::tok::kw_long: case clang::tok::kw_short: case clang::tok::kw_char: Consume(); Result += " " + Spelling(); continue; } break; } } else { while(Test(clang::tok::kw_int) || Test(clang::tok::kw_long) || Test(clang::tok::kw_short) || Test(clang::tok::kw_char) || Test(clang::tok::kw_void) || Test(clang::tok::kw_bool) || Test(clang::tok::kw_double) || Test(clang::tok::kw_float)) { if (!Result.empty()) Result += " "; Result += Spelling(); } } if (Result.empty()) { clang::CXXScopeSpec SS; if (Test(clang::tok::coloncolon)) { SS.MakeGlobal(Sema.getASTContext(), OriginalLocation()); Result += Spelling(); } do { if (!Test(clang::tok::identifier)) { PP.getDiagnostics().Report(OriginalLocation(CurrentTok.getLocation()), PP.getDiagnostics().getCustomDiagID(clang::DiagnosticsEngine::Error, "Invalid token while parsing type")); return {}; } Result += Spelling(); if (Test(clang::tok::less)) { NoTemplates = false; Result += "<"; Result += parseTemplateType(); if (!PrevToken.is(clang::tok::greater)) { PP.getDiagnostics().Report(OriginalLocation(CurrentTok.getLocation()), PP.getDiagnostics().getCustomDiagID(clang::DiagnosticsEngine::Error, "parse error in type")); return {}; //error; } } clang::Token IdentTok = PrevToken; if (!Test(clang::tok::coloncolon)) break; if (NoTemplates && !SupressDiagnostics) { if (Sema.ActOnCXXNestedNameSpecifier(Sema.getScopeForContext(RD), *IdentTok.getIdentifierInfo(), OriginalLocation(IdentTok.getLocation()), OriginalLocation(CurrentTok.getLastLoc()), {}, false, SS)) SS.SetInvalid({OriginalLocation(IdentTok.getLocation()), OriginalLocation(CurrentTok.getLastLoc())}); } Result += Spelling(); } while (true); if (NoTemplates && !SupressDiagnostics) { IsEnum = true; // That's how moc does it. if (SS.isNotEmpty() && SS.isValid()) { Extra = llvm::dyn_cast_or_null<clang::CXXRecordDecl>(Sema.computeDeclContext(SS)); clang::LookupResult Found(Sema, PrevToken.getIdentifierInfo(), OriginalLocation(), clang::Sema::LookupNestedNameSpecifierName); /*if (SS.isEmpty()) Sema.LookupQualifiedName(Found, RD); else {*/ clang::DeclContext* DC = Sema.computeDeclContext(SS); Sema.LookupQualifiedName(Found, DC ? DC : RD); //} clang::EnumDecl* R = Found.getAsSingle<clang::EnumDecl>(); /*if (!R) { if (clang::TypedefDecl *TD = Found.getAsSingle<clang::TypedefDecl>()) { const clang::TemplateSpecializationType* TDR = TD->getUnderlyingType()->getAs<clang::TemplateSpecializationType>(); if(TDR && TDR->getNumArgs() == 1 && TDR->getTemplateName().getAsTemplateDecl()->getName() == "QFlags") { if (const clang::EnumType* ET = TDR->getArg(0).getAsType()->getAs<clang::EnumType>()) R = ET->getDecl(); } }*/ /*if (!R) IsEnum = false;*/ if(Extra) { bool isQObjectOrQGadget = false; for (auto it = Extra->decls_begin(); it != Extra->decls_end(); ++it) { auto ND = llvm::dyn_cast<clang::NamedDecl>(*it); if (ND && ND->getIdentifier() && ND->getName() == "staticMetaObject") { isQObjectOrQGadget = true; break; } } if (!isQObjectOrQGadget) Extra = nullptr; } if (!R) { clang::CXXRecordDecl* D = Found.getAsSingle<clang::CXXRecordDecl>(); if (D && !D->hasDefinition()) IsPossiblyForwardDeclared = true; } } else if (SS.isEmpty()) { clang::LookupResult Found(Sema, PrevToken.getIdentifierInfo(), OriginalLocation(), clang::Sema::LookupNestedNameSpecifierName); Sema.LookupName(Found, Sema.getScopeForContext(RD)); clang::CXXRecordDecl* D = Found.getAsSingle<clang::CXXRecordDecl>(); if (D && !D->hasDefinition()) { IsPossiblyForwardDeclared = true; } Found.suppressDiagnostics(); } } } if (NoTemplates && Test(clang::tok::kw_const)) { // The official moc don't move the const if there are templates HasConst = true; } while (Test(clang::tok::kw_volatile) || Test(clang::tok::star) || Test(clang::tok::kw_const)) { Extra = nullptr; IsEnum = false; Result += Spelling(); } if (Test(clang::tok::amp)) { if (HasConst) HasConst = false; // remove const reference else Result += Spelling(); } else { Test(clang::tok::ampamp); // skip rvalue ref } if (HasVolatile) Result = "volatile " + Result; if (HasConst) Result = "const " + Result; return Result; }
// 1 // \ // 2 // \ // 3 // \ // 4 // \ // 5 void Test4() { int data[] = {5, 4, 3, 2, 1}; Test("Test4", data, sizeof(data)/sizeof(int), true); }
// 5 // / // 4 // / // 3 // / // 2 // / // 1 void Test3() { int data[] = {1, 2, 3, 4, 5}; Test("Test3", data, sizeof(data)/sizeof(int), true); }
// 5 // / \ // 4 7 // / // 6 void Test2() { int data[] = {4, 6, 7, 5}; Test("Test2", data, sizeof(data)/sizeof(int), true); }
int main(int argc, char **argv) { int i; PRThread *thread; PRFileDesc *sock; PRNetAddr addr; memset(&addr, 0, sizeof(addr)); addr.inet.family = PR_AF_INET; addr.inet.port = PR_htons(0); addr.inet.ip = PR_htonl(PR_INADDR_ANY); for (i = 0; i < POLL_DESC_COUNT; i++) { sock = PR_NewTCPSocket(); if (sock == NULL) { fprintf(stderr, "PR_NewTCPSocket failed\n"); exit(1); } if (PR_Bind(sock, &addr) == PR_FAILURE) { fprintf(stderr, "PR_Bind failed\n"); exit(1); } if (PR_Listen(sock, 5) == PR_FAILURE) { fprintf(stderr, "PR_Listen failed\n"); exit(1); } pd[i].fd = sock; pd[i].in_flags = PR_POLL_READ; } /* first run the test on the primordial thread */ Test(); /* then run the test on all three kinds of threads */ thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0); if (NULL == thread) { fprintf(stderr, "PR_CreateThread failed\n"); exit(1); } if (PR_JoinThread(thread) == PR_FAILURE) { fprintf(stderr, "PR_JoinThread failed\n"); exit(1); } thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0); if (NULL == thread) { fprintf(stderr, "PR_CreateThread failed\n"); exit(1); } if (PR_JoinThread(thread) == PR_FAILURE) { fprintf(stderr, "PR_JoinThread failed\n"); exit(1); } thread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, NULL, PR_PRIORITY_NORMAL, PR_GLOBAL_BOUND_THREAD, PR_JOINABLE_THREAD, 0); if (NULL == thread) { fprintf(stderr, "PR_CreateThread failed\n"); exit(1); } if (PR_JoinThread(thread) == PR_FAILURE) { fprintf(stderr, "PR_JoinThread failed\n"); exit(1); } for (i = 0; i < POLL_DESC_COUNT; i++) { if (PR_Close(pd[i].fd) == PR_FAILURE) { fprintf(stderr, "PR_Close failed\n"); exit(1); } } PR_Cleanup(); printf("PASS\n"); return 0; }
/********************************************************************* * Function: void APP_DeviceCustomHIDTasks(void); * * Overview: Keeps the Custom HID demo running. * * PreCondition: The demo should have been initialized and started via * the APP_DeviceCustomHIDInitialize() and APP_DeviceCustomHIDStart() demos * respectively. * * Input: None * * Output: None * ********************************************************************/ void APP_DeviceCustomHIDTasks() { //Check if we have received an OUT data packet from the host if(HIDRxHandleBusy(USBOutHandle) == false) { //We just received a packet of data from the USB host. //Check the first uint8_t of the packet to see what command the host //application software wants us to fulfill. switch(ReceivedDataBuffer[0]) //Look at the data the host sent, to see what kind of application specific command it sent. { case READ_SFR: ReadSfr(); break; case WRITE_SFR: WriteSfr(); break; case ADC_CFG: AdcCfg(); break; case ADC_VALUE: AdcValue(); break; case ANALOGCMP_CFG: AnalogCmpCfg(); break; case SPI_CFG: SpiCfg(); break; case SPI_TRANSFERENCE: SpiTransference(); break; case SFR_CHANGE_BIT_VALUE: SfrChangeBitValue(); break; case I2C_CFG: I2cCfg(); break; case I2C_TRANSFERENCE: I2cTransference(); break; case CCP_CFG: CcpCfg(); break; case PWM_FPWM: PwmFpwm(); break; case PWM_DC: PwmDc(); break; case SFR_READ_BIT_VALUE: SfrReadBitValue(); break; case EUSART_TX: EusartTx(); break; case EUSART_RX: EusartRx(); break; case TEST: Test(); break; case UDF_CALL: UDF(); break; case UDF_PROGRAM: UDF_Program(); break; } //Re-arm the OUT endpoint, so we can receive the next OUT data packet //that the host may try to send us. USBOutHandle = HIDRxPacket(CUSTOM_DEVICE_HID_EP, (uint8_t*)&ReceivedDataBuffer, 64); } }
s32 Init() { numBuffers = Config_WaveOut.NumBuffers; MMRESULT woores; if (Test()) return -1; // TODO : Use dsound to determine the speaker configuration, and expand audio from there. #if 0 int speakerConfig; //if( StereoExpansionEnabled ) speakerConfig = 2; // better not mess with this in wavout :p (rama) // Any windows driver should support stereo at the software level, I should think! pxAssume( speakerConfig > 1 ); LPTHREAD_START_ROUTINE threadproc; switch( speakerConfig ) { case 2: ConLog( "* SPU2 > Using normal 2 speaker stereo output.\n" ); threadproc = (LPTHREAD_START_ROUTINE)&RThread<StereoOut16>; speakerConfig = 2; break; case 4: ConLog( "* SPU2 > 4 speaker expansion enabled [quadraphenia]\n" ); threadproc = (LPTHREAD_START_ROUTINE)&RThread<StereoQuadOut16>; speakerConfig = 4; break; case 6: case 7: ConLog( "* SPU2 > 5.1 speaker expansion enabled.\n" ); threadproc = (LPTHREAD_START_ROUTINE)&RThread<Stereo51Out16>; speakerConfig = 6; break; default: ConLog( "* SPU2 > 7.1 speaker expansion enabled.\n" ); threadproc = (LPTHREAD_START_ROUTINE)&RThread<Stereo51Out16>; speakerConfig = 8; break; } #endif wformat.wFormatTag = WAVE_FORMAT_PCM; wformat.nSamplesPerSec = SampleRate; wformat.wBitsPerSample = 16; wformat.nChannels = 2; wformat.nBlockAlign = ((wformat.wBitsPerSample * wformat.nChannels) / 8); wformat.nAvgBytesPerSec = (wformat.nSamplesPerSec * wformat.nBlockAlign); wformat.cbSize = 0; qbuffer = new StereoOut16[BufferSize * numBuffers]; woores = waveOutOpen(&hwodevice, WAVE_MAPPER, &wformat, 0, 0, 0); if (woores != MMSYSERR_NOERROR) { waveOutGetErrorText(woores, (wchar_t *)&ErrText, 255); SysMessage("WaveOut Error: %s", ErrText); return -1; } const int BufferSizeBytes = wformat.nBlockAlign * BufferSize; for (u32 i = 0; i < numBuffers; i++) { whbuffer[i].dwBufferLength = BufferSizeBytes; whbuffer[i].dwBytesRecorded = BufferSizeBytes; whbuffer[i].dwFlags = 0; whbuffer[i].dwLoops = 0; whbuffer[i].dwUser = 0; whbuffer[i].lpData = (LPSTR)QBUFFER(i); whbuffer[i].lpNext = 0; whbuffer[i].reserved = 0; waveOutPrepareHeader(hwodevice, whbuffer + i, sizeof(WAVEHDR)); whbuffer[i].dwFlags |= WHDR_DONE; //avoid deadlock } // Start Thread // [Air]: The waveout code does not use wait objects, so setting a time critical // priority level is a bad idea. Standard priority will do fine. The buffer will get the // love it needs and won't suck resources idling pointlessly. Just don't try to // run it in uber-low-latency mode. waveout_running = true; thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RThread<StereoOut16>, this, 0, &tid); return 0; }
{ Chunk(5, "ALL T"), Chunk(1, "H"), Chunk(4, "ESE "), Chunk(2, "WO"), Chunk(21, "RLDS ARE YOURS EXCEPT"), Chunk(9, " EUROPA. "), Chunk(25, "ATTEMPT NO LANDING THERE."), Chunk(0, nullptr) }; static Test kTests[] = { // Test 1, test a simple round string in one chunk Test( kTest1Chunks, "SGVsbG8gc2ly" ), // Test 2, test a simple round string split into round chunks Test( kTest2Chunks, "SGVsbG8gc2ly" ), // Test 3, test a single chunk that's 2 short Test( kTest3Chunks, "SQ==" ), // Test 4, test a single chunk that's 1 short Test( kTest4Chunks, "SGk="
void TestSuite :: AddTest( const std::string & name, TestFunction func ) { mTests.push_back( Test( name, func ) ); }
int main(int argc, char* argv[]) { Test("Test01", "", "", true); Test("Test02", "", ".*", true); Test("Test03", "", ".", false); Test("Test04", "", "c*", true); Test("Test05", "a", ".*", true); Test("Test06", "a", "a.", false); Test("Test07", "a", "", false); Test("Test08", "a", ".", true); Test("Test09", "a", "ab*", true); Test("Test10", "a", "ab*a", false); Test("Test11", "aa", "aa", true); Test("Test12", "aa", "a*", true); Test("Test13", "aa", ".*", true); Test("Test14", "aa", ".", false); Test("Test15", "ab", ".*", true); Test("Test16", "ab", ".*", true); Test("Test17", "aaa", "aa*", true); Test("Test18", "aaa", "aa.a", false); Test("Test19", "aaa", "a.a", true); Test("Test20", "aaa", ".a", false); Test("Test21", "aaa", "a*a", true); Test("Test22", "aaa", "ab*a", false); Test("Test23", "aaa", "ab*ac*a", true); Test("Test24", "aaa", "ab*a*c*a", true); Test("Test25", "aaa", ".*", true); Test("Test26", "aab", "c*a*b", true); Test("Test27", "aaca", "ab*a*c*a", true); Test("Test28", "aaba", "ab*a*c*a", false); Test("Test29", "bbbba", ".*a*a", true); Test("Test30", "bcbbabab", ".*a*a", false); return 0; }
// Null pointer void Test3() { Test("Test3", NULL, NULL); }
int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT DCOCTL = 0; // Select lowest DCOx and MODx settings BCSCTL1 = CALBC1_8MHZ; // Set DCO DCOCTL = CALDCO_8MHZ; BCSCTL1 |= DIVA_1; // ACLK /(0:1,1:2,2:4,3:8) BCSCTL2 |= DIVS_0; // SMCLK/(0:1,1:2,2:4,3:8) BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO (select SMCLK source) // 8000000 Hz 9600 bps UCA0BR0 = 0x41; UCA0BR1 = 0x03; UCA0MCTL = UCBRS_3 + UCBRF_0; //16MHz 9600 bps /*UCA0BR0 = 0x82; // 16MHz 9600 UCA0BR1 = 0x06; // 16MHz 9600 UCA0MCTL = UCBRS_5 + UCBRF_0; // Modulation UCBRSx = 3*/ P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD // Set GPIO functions P2SEL &= 0xBF; // P2.0-P2.5 = cap sense, P2.6 = I/O P2SEL2 &= 0xBF; // P2.0-P2.5 = cap sense, P2.6 = I/O P3SEL |= 0x04; // P3.2 = PWM Output // Set GPIO directions P1DIR |= (BUTTON1+BUTTON2+BUTTON3+BUTTON4); // Set P1.0-P1.3 to outputs for colored LEDs P2DIR |= 0x40; // Set P2.6 = Output P3DIR |= (MODE0+MODE1+MODE2+MODE3+MODE4+BIT2+BIT1+BIT0); // Set P3.0-P3.1, P3.3-P3.7 as outputs = LRA/^ERM, EN, M0-M4 // Set GPIO values P1OUT = 0; // Colored LEDs off P2OUT |= 0x40; // Set P2.6 = 1, set load switch to LRA P3OUT = 0x00; // White LEDs off, EN = off // TimerA Setup // Set PWM Frequency, TimerA gives 255 counts at SMCLK frequency TA1CCR0 = 0x00FF; UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt CapTouch_Init(); Haptics_Init(); //These will engage just fine // CapTouch_PowerUpSequence(); Haptics_SendWaveform(erm_rampup); for(;;) { __bis_SR_register(GIE); write(character); if(character == 'a') { printf(" Successfully pressed 'a'! \r\n"); //THIS IS WHERE THINGS BREAK //Haptics_SendWaveform(erm_rampup); Test(); } character = 0x00; //This works just fine //Haptics_SendWaveform(erm_rampup); } }
int main(int argc, char* argv[]) { nsresult rv; if (argc < 2) { printf("usage: %s <in-dir> <out-dir>\n", argv[0]); return -1; } char* inDir = argv[1]; char* outDir = argv[2]; { nsCOMPtr<nsIServiceManager> servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); if (registrar) registrar->AutoRegister(nsnull); nsCOMPtr<nsILocalFile> inDirFile; rv = NS_NewNativeLocalFile(nsDependentCString(inDir), PR_FALSE, getter_AddRefs(inDirFile)); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsILocalFile> outDirFile; rv = NS_NewNativeLocalFile(nsDependentCString(outDir), PR_FALSE, getter_AddRefs(outDirFile)); if (NS_FAILED(rv)) return rv; CreateFun create = FileChannelWorker::Create; Test(create, 1, inDirFile, outDirFile, 16 * 1024); #if 1 printf("FileChannelWorker *****************************\n"); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); #endif create = FileSpecWorker::Create; printf("FileSpecWorker ********************************\n"); #if 1 Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); Test(create, 20, inDirFile, outDirFile, 16 * 1024); #endif #if 1 Test(create, 20, inDirFile, outDirFile, 4 * 1024); Test(create, 20, inDirFile, outDirFile, 4 * 1024); Test(create, 20, inDirFile, outDirFile, 4 * 1024); Test(create, 20, inDirFile, outDirFile, 4 * 1024); Test(create, 20, inDirFile, outDirFile, 4 * 1024); Test(create, 20, inDirFile, outDirFile, 4 * 1024); Test(create, 20, inDirFile, outDirFile, 4 * 1024); Test(create, 20, inDirFile, outDirFile, 4 * 1024); Test(create, 20, inDirFile, outDirFile, 4 * 1024); #endif } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM rv = NS_ShutdownXPCOM(nsnull); NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); return 0; }
void loop() { delay(2000); Test(); delay(8000); }
ribi::QtToolTestApproximatorXyzMainDialog::QtToolTestApproximatorXyzMainDialog(QWidget *parent) noexcept : QtHideAndShowDialog(parent), ui(new Ui::QtToolTestApproximatorXyzMainDialog), m_approximator(), m_data(CreateData()) { #ifndef NDEBUG Test(); #endif ui->setupUi(this); //Set up the plots and curves GetPlot(0)->setTitle("Approximator, for z = 0.0"); GetPlot(1)->setTitle("Approximator, for z = 0.5"); GetPlot(2)->setTitle("Approximator, for z = 1.0"); for (auto i=0; i!=m_n_curves; ++i) { const auto plot = GetPlot(i); plot->setAxisTitle(QwtPlot::xBottom,"X"); plot->setAxisTitle(QwtPlot::yLeft,"Y"); #ifdef _WIN32 plot->setCanvasBackground(QBrush(QColor(255,255,255))); #else plot->setCanvasBackground(QColor(255,255,255)); #endif const auto curve_values = GetCurveValues(i); assert(curve_values); curve_values->setTitle("Points"); curve_values->attach(plot.get()); curve_values->setStyle(QwtPlotCurve::Dots); curve_values->setPen(QPen(QColor(255,0,0),5)); const auto curve_approximation = GetCurveApproximation(i); assert(curve_approximation); curve_approximation->setTitle("Approximation"); curve_approximation->attach(plot.get()); curve_approximation->setStyle(QwtPlotCurve::Dots); curve_approximation->setPen(QPen(QColor(0,0,255),3)); //Add grid { QwtPlotGrid * const grid = new QwtPlotGrid; grid->setPen(QPen(QColor(128,128,128))); grid->attach(plot.get()); } //Add zoomer { new QwtPlotZoomer(plot->canvas()); } //Add legend { QwtLegend * const legend = new QwtLegend; legend->setFrameStyle(QFrame::Box|QFrame::Sunken); plot->insertLegend(legend, QwtPlot::RightLegend); } plot->setAxisScale( QwtPlot::xBottom, static_cast<double>(ui->box_int_x->minimum()), static_cast<double>(ui->box_int_x->maximum()) ); plot->setAxisScale( QwtPlot::yLeft, static_cast<double>(ui->box_double_y->minimum()), static_cast<double>(ui->box_double_y->maximum()) ); //Add to dialog assert(ui->verticalLayout->layout()); ui->verticalLayout->layout()->addWidget(plot.get()); } //Add some nice testing values ui->box_int_x->setValue(ui->box_int_x->minimum() / 2); ui->box_double_y->setValue(ui->box_double_y->maximum() / 2.0); on_button_clicked(); ui->box_int_x->setValue(ui->box_int_x->minimum() / 4); ui->box_double_y->setValue(ui->box_double_y->minimum() / 2.0); on_button_clicked(); ui->box_int_x->setValue(ui->box_int_x->maximum() / 4); ui->box_double_y->setValue(ui->box_double_y->maximum() / 2.0); on_button_clicked(); ui->box_int_x->setValue(ui->box_int_x->maximum() / 2); ui->box_double_y->setValue(ui->box_double_y->minimum() / 2.0); on_button_clicked(); ui->box_int_x->setValue(0); ui->box_double_y->setValue(0.0); }
// Empty tree void Test7() { Test("Test7", NULL, true); }
int _tmain(int argc, _TCHAR* argv[]) { /* 1 */ Test(1, 1); /* 1 2 3 4 */ Test(2, 2); /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ Test(4, 4); /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 */ Test(5, 5); /* 1 2 3 4 5 */ Test(1, 5); /* 1 2 3 4 5 6 7 8 9 10 */ Test(2, 5); /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ Test(3, 5); /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ Test(4, 5); /* 1 2 3 4 5 */ Test(5, 1); /* 1 2 3 4 5 6 7 8 9 10 */ Test(5, 2); /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ Test(5, 3); /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ Test(5, 4); return 0; }
static void ThreadFunc(void *arg) { Test(); }
int main() { Test(); //Test1(); return 0; }
// empty void Test8() { Test("Test8", NULL, 0, false); }