コード例 #1
0
void ToolsRhoEstimator::on_radio_toggled(bool checked) {
  checked = true;  // hack to avoid the "unused parameter" g++ warning

  if (impBut->isChecked()) {
    // we just changed from metric --> imperial, so relabel and do the
    // field conversions for the user.
    tempSpinBox->setValue(celsius_to_fahrenheit(tempSpinBox->value()));
    tempLabel->setText(tr("Temperature (F):"));
    pressSpinBox->setValue(
        hectopascals_to_inchesmercury(pressSpinBox->value()));
    pressLabel->setText(tr("Air Pressure (inHg):"));
    dewpSpinBox->setValue(celsius_to_fahrenheit(dewpSpinBox->value()));
    dewpLabel->setText(tr("Dewpoint (F):"));
  } else {
    // we just changed from imperial --> metric, so relabel and do the
    // field conversions for the user.
    tempSpinBox->setValue(fahrenheit_to_celsius(tempSpinBox->value()));
    tempLabel->setText(tr("Temperature (C):"));
    pressSpinBox->setValue(
        inchesmercury_to_hectopascals(pressSpinBox->value()));
    pressLabel->setText(tr("Air Pressure (hPa):"));
    dewpSpinBox->setValue(fahrenheit_to_celsius(dewpSpinBox->value()));
    dewpLabel->setText(tr("Dewpoint (C):"));
  }

  // Relay the "something has changed" signal to
  // on_valueChanged(double).
  this->on_valueChanged(0.0);
}
コード例 #2
0
ファイル: temp_converter.cpp プロジェクト: mdeilman/cpptut
void test_celsius_to_fahrenheit(){

  assert( celsius_to_fahrenheit(15) == static_cast<double>(59.0) );
  std::cout << "Execution continues past the first test" << std::endl;
  assert( celsius_to_fahrenheit(19) == static_cast<double>(66.2) );
  std::cout << "Execution continues past the second test" << std::endl;
  assert( celsius_to_fahrenheit(23) == static_cast<double>(73.4) );
  std::cout << "Execution continues past the third test" << std::endl;
  std::cout << "All tests passed" << std::endl;
}