Commit 87520173 authored by Meade's avatar Meade

Added version 8.1.0. See README.md for changes.

parent 1bbd78f3
Pipeline #46908709 passed with stage
in 5 minutes and 22 seconds
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/rust/tags/
image: "rust:latest"
# Optional: Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
#services:
# - mysql:latest
# - redis:latest
# - postgres:latest
# Optional: Install a C compiler, cmake and git into the container.
# You will often need this when you (or any of your dependencies) depends on C code.
before_script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends build-essential libgtk-3-dev
# Use cargo to test the project
test:cargo:
stages:
- cargo-test
brewstillery:
stage: cargo-test
script:
- rustc --version && cargo --version # Print version info for debugging
- cargo test --all --verbose
- rustc --version && cargo --version
- cargo test --all --verbose
\ No newline at end of file
This diff is collapsed.
[package]
name = "BrewStillery"
version = "8.0.0"
version = "8.1.0"
authors = ["Meade <thedarkula2049@gmail.com>", "Emily <marleybrush5@gmail.com>"]
description = "BrewStillery is a brewer's, vintner's, and distiller's calculator. It has a multitude of great functions, such as calculating ABV, determining carbonation, and total sparge water needed."
# documentation to come
......@@ -11,6 +11,7 @@ readme = "README.md"
keywords = ["beer", "wine", "champagne", "distilling", "calculator"]
categories = ["science", "gui"]
license = "AGPL-3.0"
edition = "2018"
[badges]
maintenance = { status = "actively-developed" }
......@@ -22,7 +23,8 @@ features = ["v3_22"]
[dependencies]
gdk = "0.9.0"
gio = "0.5.0"
rayon = "1.0.2"
rayon = "1.0.3"
approx = "0.3.1"
[features]
default = []
......
......@@ -4,20 +4,12 @@ It has a multitude of great functions, such as calculating ABV, determining carb
Written in Rust, using GTK3
## New In 8.0.0
* Created `enumImplementations.rs`, which includes a massive
improvement in how we go from a `String` coming from gtk to our enums.
* Got rid of the binary search in `increaseABV`, because we weren't actually using it.
We couldn't because of the initial problem of not being able to invert the formula algebraically.
We did change the while loop into a parallel iterator using `rayon`. It now runs on as many
cores as your computer has.
* We also parallelised other loops which caused a huge performance increase.
* Created `structImplementations.rs` and cleaned up the `match` statement
in `grainToABV.rs`.
* Updated `BrewStilleryIcon.svg` to be a path so it renders correctly on all systems.
* Changed `grainToGravity()` to be called `mashToGravity()`
* Updated `BrewStillery.css` to highlight ComboBoxes
* Updated and added more tests.
## New In 8.1.0
* Now using the `approx` crate for floating point testing.
* We made our `use` lines explicit.
* Updated to the Rust 2018 edition.
* Added a sanity guard to `waterSparge.rs`.
* And added more testing for waterSparge.
## Full Changelog
* [Available Here](CHANGELOG.md)
......
use gtk;
use gtk::prelude::*;
use gtk::ComboBoxExt;
use std::fmt;
use std::str::FromStr;
use enums::generalEnums::{imperialOrMetric, grainTypes, glassTypes};
use crate::enums::generalEnums::{imperialOrMetric, grainTypes, glassTypes};
impl FromStr for imperialOrMetric {
type Err = String;
......
use gtk;
use gtk::prelude::*;
use functions::commonFunctions::{inputMatching, singleInput};
use enums::generalEnums::imperialOrMetric;
use enums::enumImplementations::comboBoxTextImperialOrMetric;
use gtk::EntryExt;
use crate::functions::commonFunctions::{inputMatching, singleInput};
use crate::enums::generalEnums::imperialOrMetric;
use crate::enums::enumImplementations::comboBoxTextImperialOrMetric;
pub fn champagneCarbonationPrep(champagneCarbonationBuilder: &gtk::Builder) {
let champagneCarbonationVolume: gtk::Entry = champagneCarbonationBuilder
......
use std::f64::consts::E;
use gtk;
use std::f64::NAN;
use structs::generalStructs::colourOverlay;
use crate::structs::generalStructs::colourOverlay;
pub trait allOverlays {
fn new(&self) -> colourOverlay;
......
use gtk;
use gtk::prelude::*;
use gtk::{ColorChooserExt, EntryExt, WidgetExt};
use gdk::RGBA;
use functions::commonFunctions::{inputMatching, singleInput, mashToGravity, realABVAndAttenuation};
use constants::generalConstants::{FINAL_BRIX_IDEAL, ZERO_RGBA};
use light::lightFunctions::{singleMCU, beerSRM, grainSRMToLAB, grainLABToXYZ, grainXYZToRGBA};
use structs::generalStructs::colourOverlay;
use enums::generalEnums::{imperialOrMetric, grainTypes, glassTypes};
use enums::enumImplementations::{comboBoxTextImperialOrMetric, comboBoxTextGrainTypes,
use crate::functions::commonFunctions::{inputMatching, singleInput,
mashToGravity, realABVAndAttenuation};
use crate::constants::generalConstants::{FINAL_BRIX_IDEAL, ZERO_RGBA};
use crate::light::lightFunctions::{singleMCU, beerSRM, grainSRMToLAB,
grainLABToXYZ, grainXYZToRGBA};
use crate::structs::generalStructs::colourOverlay;
use crate::enums::generalEnums::{imperialOrMetric, grainTypes, glassTypes};
use crate::enums::enumImplementations::{comboBoxTextImperialOrMetric, comboBoxTextGrainTypes,
comboBoxTextglassTypes};
use structs::generalStructs::{LAB, XYZ};
use crate::structs::generalStructs::{LAB, XYZ};
#[derive(Debug)]
pub struct grainABVData {
......
use gtk;
use gtk::prelude::*;
use functions::commonFunctions::{inputMatching, realABVAndAttenuation};
use constants::generalConstants::FINAL_BRIX_IDEAL;
use gtk::EntryExt;
use crate::functions::commonFunctions::{inputMatching, realABVAndAttenuation};
use crate::constants::generalConstants::FINAL_BRIX_IDEAL;
pub fn guestimateABVPrep(guestimatorBuilder: &gtk::Builder) {
let guestimatorStartingBrix: gtk::Entry = guestimatorBuilder
......
use gtk;
use gtk::prelude::*;
use functions::commonFunctions::{inputMatching, singleInput, realIBU};
use enums::generalEnums::imperialOrMetric;
use enums::enumImplementations::comboBoxTextImperialOrMetric;
use gtk::EntryExt;
use crate::functions::commonFunctions::{inputMatching, singleInput, realIBU};
use crate::enums::generalEnums::imperialOrMetric;
use crate::enums::enumImplementations::comboBoxTextImperialOrMetric;
#[derive(Debug)]
pub struct guestimateIBUData {
......
use gtk;
use gtk::prelude::*;
use functions::commonFunctions::{inputMatching, singleInput};
use enums::generalEnums::imperialOrMetric;
use enums::enumImplementations::comboBoxTextImperialOrMetric;
use constants::generalConstants::FINAL_GRAVITY_IDEAL;
use gtk::EntryExt;
use crate::functions::commonFunctions::{inputMatching, singleInput};
use crate::enums::generalEnums::imperialOrMetric;
use crate::enums::enumImplementations::comboBoxTextImperialOrMetric;
use crate::constants::generalConstants::FINAL_GRAVITY_IDEAL;
#[derive(Debug)]
pub struct gyleData {
......
use gtk;
use gtk::prelude::*;
use rayon::prelude::*;
use functions::commonFunctions::{inputMatching, singleInput, realABVAndAttenuation};
use constants::generalConstants::FINAL_BRIX_IDEAL;
use enums::generalEnums::imperialOrMetric;
use enums::enumImplementations::comboBoxTextImperialOrMetric;
use gtk::EntryExt;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use crate::functions::commonFunctions::{inputMatching, singleInput, realABVAndAttenuation};
use crate::constants::generalConstants::FINAL_BRIX_IDEAL;
use crate::enums::generalEnums::imperialOrMetric;
use crate::enums::enumImplementations::comboBoxTextImperialOrMetric;
#[derive(Clone, Copy, Debug)]
pub struct increaseABVData {
......
use gtk;
use gtk::prelude::*;
use functions::commonFunctions::{inputMatching, realABVAndAttenuation};
use gtk::EntryExt;
use crate::functions::commonFunctions::{inputMatching, realABVAndAttenuation};
pub fn realABVPrep(realABVBuilder: &gtk::Builder) {
let realABVStartingBrix: gtk::Entry = realABVBuilder.get_object("realABVStartingBrix")
......
use gtk;
use gtk::prelude::*;
use functions::commonFunctions::{inputMatching, singleInput};
use enums::generalEnums::imperialOrMetric;
use enums::enumImplementations::comboBoxTextImperialOrMetric;
use gtk::EntryExt;
use crate::functions::commonFunctions::{inputMatching, singleInput};
use crate::enums::generalEnums::imperialOrMetric;
use crate::enums::enumImplementations::comboBoxTextImperialOrMetric;
#[derive(Clone, Copy, Debug)]
pub struct waterSpargeData {
......@@ -155,16 +154,6 @@ pub fn waterSpargeFormatting(allInputs: &waterSpargeData,
finalOutput.mashVolumeFinal = format!("{:.2} gallons", finalOutputFloat.mashVolume.gallonsUSToGallonsGB());
}
if finalOutputFloat.spargeVolume.gallonsUSToGallonsGB() >= 0.995 &&
finalOutputFloat.spargeVolume.gallonsUSToGallonsGB() < 1.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} gallon", finalOutputFloat.spargeVolume.gallonsUSToGallonsGB());
} else if finalOutputFloat.spargeVolume.gallonsUSToGallonsGB().fract() >= 0.995 ||
finalOutputFloat.spargeVolume.gallonsUSToGallonsGB().fract() < 0.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} gallons", finalOutputFloat.spargeVolume.gallonsUSToGallonsGB());
} else {
finalOutput.spargeVolumeFinal = format!("{:.2} gallons", finalOutputFloat.spargeVolume.gallonsUSToGallonsGB());
}
if finalOutputFloat.totalVolume.gallonsUSToGallonsGB() >= 0.995 &&
finalOutputFloat.totalVolume.gallonsUSToGallonsGB() < 1.005 {
finalOutput.totalVolumeFinal = format!("{:.0} gallon", finalOutputFloat.totalVolume.gallonsUSToGallonsGB());
......@@ -174,6 +163,20 @@ pub fn waterSpargeFormatting(allInputs: &waterSpargeData,
} else {
finalOutput.totalVolumeFinal = format!("{:.2} gallons", finalOutputFloat.totalVolume.gallonsUSToGallonsGB());
}
if finalOutputFloat.spargeVolume.gallonsUSToGallonsGB() <= 0.0 {
finalOutput.mashVolumeFinal = format!("Enter");
finalOutput.spargeVolumeFinal = format!("Valid");
finalOutput.totalVolumeFinal = format!("Inputs");
} else if finalOutputFloat.spargeVolume.gallonsUSToGallonsGB() >= 0.995 &&
finalOutputFloat.spargeVolume.gallonsUSToGallonsGB() < 1.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} gallon", finalOutputFloat.spargeVolume.gallonsUSToGallonsGB());
} else if finalOutputFloat.spargeVolume.gallonsUSToGallonsGB().fract() >= 0.995 ||
finalOutputFloat.spargeVolume.gallonsUSToGallonsGB().fract() < 0.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} gallons", finalOutputFloat.spargeVolume.gallonsUSToGallonsGB());
} else {
finalOutput.spargeVolumeFinal = format!("{:.2} gallons", finalOutputFloat.spargeVolume.gallonsUSToGallonsGB());
}
}
imperialOrMetric::ImperialUS => {
if finalOutputFloat.mashVolume >= 0.995 && finalOutputFloat.mashVolume < 1.005 {
......@@ -185,15 +188,6 @@ pub fn waterSpargeFormatting(allInputs: &waterSpargeData,
finalOutput.mashVolumeFinal = format!("{:.2} gallons", finalOutputFloat.mashVolume);
}
if finalOutputFloat.spargeVolume >= 0.995 && finalOutputFloat.spargeVolume < 1.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} gallon", finalOutputFloat.spargeVolume);
} else if finalOutputFloat.spargeVolume.fract() >= 0.995 ||
finalOutputFloat.spargeVolume.fract() < 0.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} gallons", finalOutputFloat.spargeVolume);
} else {
finalOutput.spargeVolumeFinal = format!("{:.2} gallons", finalOutputFloat.spargeVolume);
}
if finalOutputFloat.totalVolume >= 0.995 && finalOutputFloat.totalVolume < 1.005 {
finalOutput.totalVolumeFinal = format!("{:.0} gallon", finalOutputFloat.totalVolume);
} else if finalOutputFloat.totalVolume.fract() >= 0.995 ||
......@@ -202,6 +196,19 @@ pub fn waterSpargeFormatting(allInputs: &waterSpargeData,
} else {
finalOutput.totalVolumeFinal = format!("{:.2} gallons", finalOutputFloat.totalVolume);
}
if finalOutputFloat.spargeVolume <= 0.0 {
finalOutput.mashVolumeFinal = format!("Enter");
finalOutput.spargeVolumeFinal = format!("Valid");
finalOutput.totalVolumeFinal = format!("Inputs");
} else if finalOutputFloat.spargeVolume >= 0.995 && finalOutputFloat.spargeVolume < 1.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} gallon", finalOutputFloat.spargeVolume);
} else if finalOutputFloat.spargeVolume.fract() >= 0.995 ||
finalOutputFloat.spargeVolume.fract() < 0.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} gallons", finalOutputFloat.spargeVolume);
} else {
finalOutput.spargeVolumeFinal = format!("{:.2} gallons", finalOutputFloat.spargeVolume);
}
}
imperialOrMetric::Metric => {
if finalOutputFloat.mashVolume.gallonsUSToLitres() >= 0.995 &&
......@@ -214,16 +221,6 @@ pub fn waterSpargeFormatting(allInputs: &waterSpargeData,
finalOutput.mashVolumeFinal = format!("{:.2} litres", finalOutputFloat.mashVolume.gallonsUSToLitres());
}
if finalOutputFloat.spargeVolume.gallonsUSToLitres() >= 0.995 &&
finalOutputFloat.spargeVolume.gallonsUSToLitres() < 1.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} litre", finalOutputFloat.spargeVolume.gallonsUSToLitres());
} else if finalOutputFloat.spargeVolume.gallonsUSToLitres().fract() >= 0.995 ||
finalOutputFloat.spargeVolume.gallonsUSToLitres().fract() < 0.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} litres", finalOutputFloat.spargeVolume.gallonsUSToLitres());
} else {
finalOutput.spargeVolumeFinal = format!("{:.2} litres", finalOutputFloat.spargeVolume.gallonsUSToLitres());
}
if finalOutputFloat.totalVolume.gallonsUSToLitres() >= 0.995 &&
finalOutputFloat.totalVolume.gallonsUSToLitres()< 1.005 {
finalOutput.totalVolumeFinal = format!("{:.0} litre", finalOutputFloat.totalVolume.gallonsUSToLitres());
......@@ -233,6 +230,20 @@ pub fn waterSpargeFormatting(allInputs: &waterSpargeData,
} else {
finalOutput.totalVolumeFinal = format!("{:.2} litres", finalOutputFloat.totalVolume.gallonsUSToLitres());
}
if finalOutputFloat.spargeVolume.gallonsUSToLitres() <= 0.0 {
finalOutput.mashVolumeFinal = format!("Enter");
finalOutput.spargeVolumeFinal = format!("Valid");
finalOutput.totalVolumeFinal = format!("Inputs");
} else if finalOutputFloat.spargeVolume.gallonsUSToLitres() >= 0.995 &&
finalOutputFloat.spargeVolume.gallonsUSToLitres() < 1.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} litre", finalOutputFloat.spargeVolume.gallonsUSToLitres());
} else if finalOutputFloat.spargeVolume.gallonsUSToLitres().fract() >= 0.995 ||
finalOutputFloat.spargeVolume.gallonsUSToLitres().fract() < 0.005 {
finalOutput.spargeVolumeFinal = format!("{:.0} litres", finalOutputFloat.spargeVolume.gallonsUSToLitres());
} else {
finalOutput.spargeVolumeFinal = format!("{:.2} litres", finalOutputFloat.spargeVolume.gallonsUSToLitres());
}
}
}
......
......@@ -15,7 +15,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">BrewStillery</property>
<property name="subtitle">8.0.0</property>
<property name="subtitle">8.1.0</property>
<property name="show_close_button">True</property>
<child>
<placeholder/>
......@@ -2668,7 +2668,7 @@
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Version 8.0.0</property>
<property name="label" translatable="yes">Version 8.1.0</property>
</object>
<packing>
<property name="expand">False</property>
......
use gtk;
use gtk::prelude::*;
use functions::champagneCarbonation::champagneCarbonationPrep;
use gtk::{ComboBoxExt, Inhibit, WidgetExt};
use crate::functions::champagneCarbonation::champagneCarbonationPrep;
pub fn champagneCarbonationGUI(builder: &gtk::Builder) {
let champagneCarbonationVolume: gtk::Entry = builder.get_object("champagneCarbonationVolume")
......
use gtk;
use gtk::prelude::*;
use functions::grainToABV::grainToABVPrep;
use functions::commonFunctions::allOverlays;
use constants::generalConstants::ZERO_RGBA;
use gtk::{ColorButtonExt, ColorChooserExt, ComboBoxExt, Inhibit, OverlayExt, WidgetExt};
use crate::functions::grainToABV::grainToABVPrep;
use crate::functions::commonFunctions::allOverlays;
use crate::constants::generalConstants::ZERO_RGBA;
pub fn grainToABVGUI(builder: &gtk::Builder) {
let allOverlays = allOverlays::new(builder);
......
use gtk;
use gtk::prelude::*;
use gtk::{CssProviderExt, WidgetExt};
use gdk::DisplayExt;
pub fn gtkCSS(mainWindow: &gtk::ApplicationWindow) {
......
use gtk;
use gtk::prelude::*;
use functions::guestimateABV::guestimateABVPrep;
use gtk::{Inhibit, WidgetExt};
use crate::functions::guestimateABV::guestimateABVPrep;
pub fn guestimateABVGUI(builder: &gtk::Builder) {
let guestimatorStartingBrix: gtk::Entry = builder.get_object("guestimatorStartingBrix")
......
use gtk;
use gtk::prelude::*;
use functions::guestimateIBU::guestimateIBUPrep;
use gtk::{ComboBoxExt, Inhibit, WidgetExt};
use crate::functions::guestimateIBU::guestimateIBUPrep;
pub fn guestimateIBUGUI(builder: &gtk::Builder) {
let totalIBUPreBoilBrix: gtk::Entry = builder.get_object("totalIBUPreBoilBrix")
......
use gtk;
use gtk::prelude::*;
use functions::gyleCarbonation::gyleCarbonationPrep;
use gtk::{ComboBoxExt, Inhibit, WidgetExt};
use crate::functions::gyleCarbonation::gyleCarbonationPrep;
pub fn gyleCarbonationGUI(builder: &gtk::Builder) {
let gyleStartingBrix: gtk::Entry = builder.get_object("gyleStartingBrix")
......
use gtk;
use gtk::prelude::*;
use functions::increaseABV::increaseABVPrep;
use gtk::{ComboBoxExt, Inhibit, WidgetExt};
use crate::functions::increaseABV::increaseABVPrep;
pub fn increaseABVGUI(builder: &gtk::Builder) {
let increaseABVStartingBrix: gtk::Entry = builder.get_object("increaseABVStartingBrix")
......
use gtk;
use gtk::prelude::*;
use functions::realABV::realABVPrep;
use gtk::{Inhibit, WidgetExt};
use crate::functions::realABV::realABVPrep;
pub fn realABVGUI(builder: &gtk::Builder) {
let realABVStartingBrix: gtk::Entry = builder.get_object("realABVStartingBrix")
......
use gtk;
use gtk::prelude::*;
use gui::gtkCSS::gtkCSS;
use gui::guestimateABVGUI::guestimateABVGUI;
use gui::increaseABVGUI::increaseABVGUI;
use gui::grainToABVGUI::grainToABVGUI;
use gui::realABVGUI::realABVGUI;
use gui::waterSpargeGUI::waterSpargeGUI;
use gui::guestimateIBUGUI::guestimateIBUGUI;
use gui::gyleCarbonationGUI::gyleCarbonationGUI;
use gui::champagneCarbonationGUI::champagneCarbonationGUI;
use gtk::{GtkWindowExt, Inhibit, WidgetExt};
use crate::gui::gtkCSS::gtkCSS;
use crate::gui::guestimateABVGUI::guestimateABVGUI;
use crate::gui::increaseABVGUI::increaseABVGUI;
use crate::gui::grainToABVGUI::grainToABVGUI;
use crate::gui::realABVGUI::realABVGUI;
use crate::gui::waterSpargeGUI::waterSpargeGUI;
use crate::gui::guestimateIBUGUI::guestimateIBUGUI;
use crate::gui::gyleCarbonationGUI::gyleCarbonationGUI;
use crate::gui::champagneCarbonationGUI::champagneCarbonationGUI;
pub fn startGTK(application: &gtk::Application) {
......
use gtk;
use gtk::prelude::*;
use functions::waterSparge::waterSpargePrep;
use gtk::{ComboBoxExt, Inhibit, WidgetExt};
use crate::functions::waterSparge::waterSpargePrep;
pub fn waterSpargeGUI(builder: &gtk::Builder) {
let spargePreFermentVolume: gtk::Entry = builder.get_object("spargePreFermentVolume")
......
use rayon::prelude::*;
use light::colour::colourConstants::{S0DATA, S1DATA, S2DATA};
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator,
ParallelIterator};
use crate::light::colour::colourConstants::{S0DATA, S1DATA, S2DATA};
// we will make this a constant when const fn is stabilised
//pub const COMPUTED_ILLUMINANT_DATA: [f64; 81] = computedIlluminantData();
......
use rayon::prelude::*;
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator,
ParallelIterator};
use gdk::RGBA;
use light::colour::computedIlluminantData::computedIlluminantData;
use light::colour::colourConstants::{X2DATA, Y2DATA, Z2DATA};
use light::eigenVectors::eigenVectorConstants::EIGENVECTOR_AVERAGE_DATA;
use structs::generalStructs::{LAB, XYZ};
use crate::light::colour::computedIlluminantData::computedIlluminantData;
use crate::light::colour::colourConstants::{X2DATA, Y2DATA, Z2DATA};
use crate::light::eigenVectors::eigenVectorConstants::EIGENVECTOR_AVERAGE_DATA;
use crate::structs::generalStructs::{LAB, XYZ};
pub fn reconstructedTransmissionData(glassDiameter: f64, beerSRM: f64) -> [f64; 81] {
let mut reconstructedTransmissionList: [f64; 81] = [0.0; 81];
......
#[macro_export]
macro_rules! clone {
(@param _) => ( _ );
(@param $x:ident) => ( $x );
......
#[macro_use]
mod macroDefinitions;
\ No newline at end of file
pub mod macroDefinitions;
\ No newline at end of file
......@@ -4,6 +4,7 @@ extern crate gtk;
extern crate gdk;
extern crate gio;
extern crate rayon;
extern crate approx;
#[macro_use]
mod macros;
......@@ -16,9 +17,9 @@ mod structs;
#[cfg(test)]
mod tests;
use gio::prelude::*;
use gio::{ApplicationExt, ApplicationExtManual};
use std::env::args;
use gui::startGTK::startGTK;
use crate::gui::startGTK::startGTK;
fn main() {
......
use gtk::WidgetExt;
use structs::generalStructs::colourOverlay;
use crate::structs::generalStructs::colourOverlay;
impl colourOverlay {
pub fn setOverlaysInvisible(&self) {
......
use enums::generalEnums::imperialOrMetric;
use functions::champagneCarbonation::{champagneCarbonationMaths, champagneCarbonationFormatting};
use crate::enums::generalEnums::imperialOrMetric;
use crate::functions::champagneCarbonation::{champagneCarbonationMaths, champagneCarbonationFormatting};
use approx::ulps_eq;
#[test]
fn champagneMathsImperialGBTest() {
let champagneVolume: f64 = 20.0;
let imperialOrMetric: imperialOrMetric = imperialOrMetric::ImperialGB;
assert_eq!(champagneCarbonationMaths(champagneVolume, imperialOrMetric), 4.8038);
ulps_eq!(champagneCarbonationMaths(champagneVolume, imperialOrMetric), 4.8038);
}
#[test]
......@@ -14,7 +15,7 @@ fn champagneMathsImperialUSTest() {
let champagneVolume: f64 = 20.0;
let imperialOrMetric: imperialOrMetric = imperialOrMetric::ImperialUS;
assert_eq!(champagneCarbonationMaths(champagneVolume, imperialOrMetric), 4.0);
ulps_eq!(champagneCarbonationMaths(champagneVolume, imperialOrMetric), 4.0);
}
#[test]
......@@ -22,7 +23,7 @@ fn champagneMathsMetricTest() {
let champagneVolume: f64 = 60.0;
let imperialOrMetric: imperialOrMetric = imperialOrMetric::Metric;
assert_eq!(champagneCarbonationMaths(champagneVolume, imperialOrMetric), 1.437917125853319);
ulps_eq!(champagneCarbonationMaths(champagneVolume, imperialOrMetric), 1.437917125853319);
}
#[test]
......
use gdk::RGBA;
use enums::generalEnums::imperialOrMetric;
use functions::grainToABV::{grainABVData, grainToABVMaths, grainToABVFormatting, grainToABVColour};
use crate::enums::generalEnums::imperialOrMetric;
use crate::functions::grainToABV::{grainABVData, grainToABVMaths, grainToABVFormatting, grainToABVColour};
use approx::ulps_eq;
#[test]
fn grainToABVMathsImperialGBTest() {
......@@ -44,8 +45,8 @@ fn grainToABVMathsImperialGBTest() {
grainToABVMaths(&mut allInputs);
assert_eq!(allInputs.startingBrix, 13.02055777686189);
assert_eq!(allInputs.abvFinal, 6.027879973540519);
ulps_eq!(allInputs.startingBrix, 13.02055777686189);
ulps_eq!(allInputs.abvFinal, 6.027879973540519);
}
#[test]
......@@ -90,8 +91,8 @@ fn grainToABVMathsImperialUSTest() {
grainToABVMaths(&mut allInputs);
assert_eq!(allInputs.startingBrix, 15.499109502776603);
assert_eq!(allInputs.abvFinal, 7.695621290396818);
ulps_eq!(allInputs.startingBrix, 15.499109502776603);
ulps_eq!(allInputs.abvFinal, 7.695621290396818);
}
#[test]
......@@ -136,8 +137,8 @@ fn grainToABVMathsMetricTest() {
grainToABVMaths(&mut allInputs);
assert_eq!(allInputs.startingBrix, 15.520375373329689);
assert_eq!(allInputs.abvFinal, 7.710344253574942);
ulps_eq!(allInputs.startingBrix, 15.520375373329689);
ulps_eq!(allInputs.abvFinal, 7.710344253574942);
}
#[test]
......@@ -316,8 +317,8 @@ fn grainToABVColourTest() {
let finalRGBA: RGBA = grainToABVColour(&allInputs);
assert_eq!(finalRGBA.red, 0.9410550035212956);
assert_eq!(finalRGBA.green, 0.8100014920708688);
assert_eq!(finalRGBA.blue, 0.45931824333551124);
assert_eq!(finalRGBA.alpha, 1.0);
ulps_eq!(finalRGBA.red, 0.9410550035212956);
ulps_eq!(finalRGBA.green, 0.8100014920708688);
ulps_eq!(finalRGBA.blue, 0.45931824333551124);
ulps_eq!(finalRGBA.alpha, 1.0);
}
\ No newline at end of file
use functions::guestimateABV::guestimateABVFormatting;
use crate::functions::guestimateABV::guestimateABVFormatting;
#[test]
fn guestimateABVFormattingTest() {
......
use enums::generalEnums::imperialOrMetric;
use functions::guestimateIBU::{guestimateIBUData, totalIBUMaths, totalIBUFormatting};
use crate::enums::generalEnums::imperialOrMetric;
use crate::functions::guestimateIBU::{guestimateIBUData, totalIBUMaths, totalIBUFormatting};
use approx::ulps_eq;
#[test]
fn totalBUMathsImperialGBTest() {
......@@ -39,7 +40,7 @@ fn totalBUMathsImperialGBTest() {
let output: f64 = totalIBUMaths(allInputs);
assert_eq!(output, 11.230131642840979);
ulps_eq!(output, 11.230131642840979);
}