Take a story's temperature by studying its tone. Is it hopeful? Cynical? Snarky? Playful?
Marveling, Excited, Exuberant; Sad, Sympathetic
On practically every page, a character marvels at an amazing site, or expresses excitement for something to come. As Charlie walks by the chocolate factory on his way to and from school, the narrator exclaims, "Oh, how he loved that smell!" (1.22) When we first meet Willy Wonka, we get another exuberant declaration: "And what an extraordinary little man he was!" (14.2). Can you blame our characters for being so excited? The chocolate factory sounds like a pretty spectacular place.
The only times those exclamation points disappear are when the book tells us of Charlie's poverty and hunger. Here, the tone turns sad and sympathetic. We learn that "life was extremely uncomfortable" (1.8) for the Bucket family, and that "Charlie felt it worst of all." (1.14) When Mr. Bucket loses his job and the family has less food, "[Charlie's] face became frighteningly white and pinched. […] It seemed doubtful whether he could go on much longer like this without becoming dangerously ill" (10.14). Yikes. We can't help but feel sorry for the boy, and because we're nice people, we sympathize with his situation. The tone definitely helps us do that.
Dahl of course makes up for all this sadness with the ultimate happy ending. Charlie's tone is nothing but excited when he cries to his family, "Oh, you just wait and see!" (30.49)